diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-01 10:31:42 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-01 10:31:42 +0200 |
commit | 26649b4215ac68eed5601d9412d2d7ddee98b543 (patch) | |
tree | 4edfab19f676bffea7f1c048323b0520ce64b5b3 /server/lib/activitypub | |
parent | 5e77a5de40ec1dde1008c08aba0e8ec9af02cba6 (diff) | |
download | PeerTube-26649b4215ac68eed5601d9412d2d7ddee98b543.tar.gz PeerTube-26649b4215ac68eed5601d9412d2d7ddee98b543.tar.zst PeerTube-26649b4215ac68eed5601d9412d2d7ddee98b543.zip |
Ensure video existence before duplicating it
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/videos.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 3dccabe12..b1e7f20b9 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -370,13 +370,15 @@ async function refreshVideoIfNeeded (options: { | |||
370 | try { | 370 | try { |
371 | const { response, videoObject } = await fetchRemoteVideo(video.url) | 371 | const { response, videoObject } = await fetchRemoteVideo(video.url) |
372 | if (response.statusCode === 404) { | 372 | if (response.statusCode === 404) { |
373 | logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url) | ||
374 | |||
373 | // Video does not exist anymore | 375 | // Video does not exist anymore |
374 | await video.destroy() | 376 | await video.destroy() |
375 | return undefined | 377 | return undefined |
376 | } | 378 | } |
377 | 379 | ||
378 | if (videoObject === undefined) { | 380 | if (videoObject === undefined) { |
379 | logger.warn('Cannot refresh remote video: invalid body.') | 381 | logger.warn('Cannot refresh remote video %s: invalid body.', video.url) |
380 | return video | 382 | return video |
381 | } | 383 | } |
382 | 384 | ||
@@ -390,8 +392,10 @@ async function refreshVideoIfNeeded (options: { | |||
390 | channel: channelActor.VideoChannel, | 392 | channel: channelActor.VideoChannel, |
391 | updateViews: options.refreshViews | 393 | updateViews: options.refreshViews |
392 | } | 394 | } |
393 | await retryTransactionWrapper(updateVideoFromAP, updateOptions) | 395 | const videoUpdated = await retryTransactionWrapper(updateVideoFromAP, updateOptions) |
394 | await syncVideoExternalAttributes(video, videoObject, options.syncParam) | 396 | await syncVideoExternalAttributes(videoUpdated, videoObject, options.syncParam) |
397 | |||
398 | return videoUpdated | ||
395 | } catch (err) { | 399 | } catch (err) { |
396 | logger.warn('Cannot refresh video.', { err }) | 400 | logger.warn('Cannot refresh video.', { err }) |
397 | return video | 401 | return video |