diff options
Diffstat (limited to 'server/lib/job-queue/handlers/move-to-object-storage.ts')
-rw-r--r-- | server/lib/job-queue/handlers/move-to-object-storage.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts index 69b441176..f480b32cd 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/lib/job-queue/handlers/move-to-object-storage.ts | |||
@@ -11,7 +11,7 @@ import { moveToFailedMoveToObjectStorageState, moveToNextState } from '@server/l | |||
11 | import { VideoModel } from '@server/models/video/video' | 11 | import { VideoModel } from '@server/models/video/video' |
12 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' | 12 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' |
13 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' | 13 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' |
14 | import { MoveObjectStoragePayload, VideoStorage } from '@shared/models' | 14 | import { MoveObjectStoragePayload, VideoState, VideoStorage } from '@shared/models' |
15 | 15 | ||
16 | const lTagsBase = loggerTagsFactory('move-object-storage') | 16 | const lTagsBase = loggerTagsFactory('move-object-storage') |
17 | 17 | ||
@@ -45,7 +45,7 @@ export async function processMoveToObjectStorage (job: Job) { | |||
45 | if (pendingMove === 0) { | 45 | if (pendingMove === 0) { |
46 | logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id, lTags) | 46 | logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id, lTags) |
47 | 47 | ||
48 | await doAfterLastJob(video, payload.isNewVideo) | 48 | await doAfterLastJob({ video, previousVideoState: payload.previousVideoState, isNewVideo: payload.isNewVideo }) |
49 | } | 49 | } |
50 | } catch (err) { | 50 | } catch (err) { |
51 | logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTags }) | 51 | logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTags }) |
@@ -91,7 +91,13 @@ async function moveHLSFiles (video: MVideoWithAllFiles) { | |||
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | async function doAfterLastJob (video: MVideoWithAllFiles, isNewVideo: boolean) { | 94 | async function doAfterLastJob (options: { |
95 | video: MVideoWithAllFiles | ||
96 | previousVideoState: VideoState | ||
97 | isNewVideo: boolean | ||
98 | }) { | ||
99 | const { video, previousVideoState, isNewVideo } = options | ||
100 | |||
95 | for (const playlist of video.VideoStreamingPlaylists) { | 101 | for (const playlist of video.VideoStreamingPlaylists) { |
96 | if (playlist.storage === VideoStorage.OBJECT_STORAGE) continue | 102 | if (playlist.storage === VideoStorage.OBJECT_STORAGE) continue |
97 | 103 | ||
@@ -115,7 +121,7 @@ async function doAfterLastJob (video: MVideoWithAllFiles, isNewVideo: boolean) { | |||
115 | await remove(getHLSDirectory(video)) | 121 | await remove(getHLSDirectory(video)) |
116 | } | 122 | } |
117 | 123 | ||
118 | await moveToNextState(video, isNewVideo) | 124 | await moveToNextState({ video, previousVideoState, isNewVideo }) |
119 | } | 125 | } |
120 | 126 | ||
121 | async function onFileMoved (options: { | 127 | async function onFileMoved (options: { |