]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Improve logging when cannot fetch remote videos
authorChocobozzz <me@florianbigard.com>
Fri, 23 Mar 2018 08:10:49 +0000 (09:10 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 23 Mar 2018 08:10:49 +0000 (09:10 +0100)
server/lib/activitypub/videos.ts

index 907fe458d57ffa179e1d2de9ae133a1597629b6d..2a66366256e0cf9da1f13ca869f66f21e898f567 100644 (file)
@@ -177,7 +177,9 @@ async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor:
 
 async function getOrCreateAccountAndVideoAndChannel (videoObject: VideoTorrentObject | string, actor?: ActorModel) {
   if (typeof videoObject === 'string') {
-    const videoFromDatabase = await VideoModel.loadByUrlAndPopulateAccount(videoObject)
+    const videoUrl = videoObject
+
+    const videoFromDatabase = await VideoModel.loadByUrlAndPopulateAccount(videoUrl)
     if (videoFromDatabase) {
       return {
         video: videoFromDatabase,
@@ -186,8 +188,8 @@ async function getOrCreateAccountAndVideoAndChannel (videoObject: VideoTorrentOb
       }
     }
 
-    videoObject = await fetchRemoteVideo(videoObject)
-    if (!videoObject) throw new Error('Cannot fetch remote video (maybe invalid...)')
+    videoObject = await fetchRemoteVideo(videoUrl)
+    if (!videoObject) throw new Error('Cannot fetch remote video with url: ' + videoUrl)
   }
 
   if (!actor) {
@@ -268,9 +270,12 @@ async function addVideoShares (instance: VideoModel, shareUrls: string[]) {
       json: true,
       activityPub: true
     })
-    const actorUrl = body.actor
-    if (!actorUrl) continue
+    if (!body || !body.actor) {
+      logger.warn('Cannot add remote share with url: %s, skipping...', shareUrl)
+      continue
+    }
 
+    const actorUrl = body.actor
     const actor = await getOrCreateActorAndServerAndModel(actorUrl)
 
     const entry = {