aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/activitypub/videos.ts10
-rw-r--r--server/lib/schedulers/videos-redundancy-scheduler.ts25
2 files changed, 28 insertions, 7 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
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index d324adfd0..11ee05a53 100644
--- a/server/lib/schedulers/videos-redundancy-scheduler.ts
+++ b/server/lib/schedulers/videos-redundancy-scheduler.ts
@@ -12,6 +12,7 @@ import { sendCreateCacheFile, sendUpdateCacheFile } from '../activitypub/send'
12import { VideoModel } from '../../models/video/video' 12import { VideoModel } from '../../models/video/video'
13import { getVideoCacheFileActivityPubUrl } from '../activitypub/url' 13import { getVideoCacheFileActivityPubUrl } from '../activitypub/url'
14import { removeVideoRedundancy } from '../redundancy' 14import { removeVideoRedundancy } from '../redundancy'
15import { getOrCreateVideoAndAccountAndChannel } from '../activitypub'
15 16
16export class VideosRedundancyScheduler extends AbstractScheduler { 17export class VideosRedundancyScheduler extends AbstractScheduler {
17 18
@@ -109,16 +110,32 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
109 const serverActor = await getServerActor() 110 const serverActor = await getServerActor()
110 111
111 for (const file of filesToDuplicate) { 112 for (const file of filesToDuplicate) {
113 // We need more attributes and check if the video still exists
114 const getVideoOptions = {
115 videoObject: file.Video.url,
116 syncParam: { likes: false, dislikes: false, shares: false, comments: false, thumbnail: false, refreshVideo: true },
117 fetchType: 'only-video' as 'only-video'
118 }
119 const { video } = await getOrCreateVideoAndAccountAndChannel(getVideoOptions)
120
112 const existing = await VideoRedundancyModel.loadLocalByFileId(file.id) 121 const existing = await VideoRedundancyModel.loadLocalByFileId(file.id)
113 if (existing) { 122 if (existing) {
114 await this.extendsExpirationOf(existing, redundancy.minLifetime) 123 if (video) {
124 await this.extendsExpirationOf(existing, redundancy.minLifetime)
125 } else {
126 logger.info('Destroying existing redundancy %s, because the associated video does not exist anymore.', existing.url)
127
128 await existing.destroy()
129 }
115 130
116 continue 131 continue
117 } 132 }
118 133
119 // We need more attributes and check if the video still exists 134 if (!video) {
120 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(file.Video.id) 135 logger.info('Video %s we want to duplicate does not existing anymore, skipping.', file.Video.url)
121 if (!video) continue 136
137 continue
138 }
122 139
123 logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, redundancy.strategy) 140 logger.info('Duplicating %s - %d in videos redundancy with "%s" strategy.', video.url, file.resolution, redundancy.strategy)
124 141