diff options
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r-- | server/lib/activitypub/videos.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index a5f58dd01..d484edd36 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -30,7 +30,7 @@ import { isArray } from '../../helpers/custom-validators/misc' | |||
30 | import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' | 30 | import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos' |
31 | import { deleteNonExistingModels, resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils' | 31 | import { deleteNonExistingModels, resetSequelizeInstance, retryTransactionWrapper } from '../../helpers/database-utils' |
32 | import { logger } from '../../helpers/logger' | 32 | import { logger } from '../../helpers/logger' |
33 | import { doJSONRequest } from '../../helpers/requests' | 33 | import { doJSONRequest, PeerTubeRequestError } from '../../helpers/requests' |
34 | import { fetchVideoByUrl, getExtFromMimetype, VideoFetchByUrlType } from '../../helpers/video' | 34 | import { fetchVideoByUrl, getExtFromMimetype, VideoFetchByUrlType } from '../../helpers/video' |
35 | import { | 35 | import { |
36 | ACTIVITY_PUB, | 36 | ACTIVITY_PUB, |
@@ -523,14 +523,7 @@ async function refreshVideoIfNeeded (options: { | |||
523 | : await VideoModel.loadByUrlAndPopulateAccount(options.video.url) | 523 | : await VideoModel.loadByUrlAndPopulateAccount(options.video.url) |
524 | 524 | ||
525 | try { | 525 | try { |
526 | const { statusCode, videoObject } = await fetchRemoteVideo(video.url) | 526 | const { videoObject } = await fetchRemoteVideo(video.url) |
527 | if (statusCode === HttpStatusCode.NOT_FOUND_404) { | ||
528 | logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url) | ||
529 | |||
530 | // Video does not exist anymore | ||
531 | await video.destroy() | ||
532 | return undefined | ||
533 | } | ||
534 | 527 | ||
535 | if (videoObject === undefined) { | 528 | if (videoObject === undefined) { |
536 | logger.warn('Cannot refresh remote video %s: invalid body.', video.url) | 529 | logger.warn('Cannot refresh remote video %s: invalid body.', video.url) |
@@ -554,6 +547,14 @@ async function refreshVideoIfNeeded (options: { | |||
554 | 547 | ||
555 | return video | 548 | return video |
556 | } catch (err) { | 549 | } catch (err) { |
550 | if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) { | ||
551 | logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url) | ||
552 | |||
553 | // Video does not exist anymore | ||
554 | await video.destroy() | ||
555 | return undefined | ||
556 | } | ||
557 | |||
557 | logger.warn('Cannot refresh video %s.', options.video.url, { err }) | 558 | logger.warn('Cannot refresh video %s.', options.video.url, { err }) |
558 | 559 | ||
559 | ActorFollowScoreCache.Instance.addBadServerId(video.VideoChannel.Actor.serverId) | 560 | ActorFollowScoreCache.Instance.addBadServerId(video.VideoChannel.Actor.serverId) |