aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/move-to-object-storage.ts17
1 files changed, 13 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 9e39322a8..69b441176 100644
--- a/server/lib/job-queue/handlers/move-to-object-storage.ts
+++ b/server/lib/job-queue/handlers/move-to-object-storage.ts
@@ -1,7 +1,7 @@
1import { Job } from 'bull' 1import { Job } from 'bull'
2import { remove } from 'fs-extra' 2import { remove } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { logger } from '@server/helpers/logger' 4import { logger, loggerTagsFactory } from '@server/helpers/logger'
5import { updateTorrentMetadata } from '@server/helpers/webtorrent' 5import { updateTorrentMetadata } from '@server/helpers/webtorrent'
6import { CONFIG } from '@server/initializers/config' 6import { CONFIG } from '@server/initializers/config'
7import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants' 7import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants'
@@ -13,6 +13,8 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info'
13import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' 13import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models'
14import { MoveObjectStoragePayload, VideoStorage } from '@shared/models' 14import { MoveObjectStoragePayload, VideoStorage } from '@shared/models'
15 15
16const lTagsBase = loggerTagsFactory('move-object-storage')
17
16export async function processMoveToObjectStorage (job: Job) { 18export async function processMoveToObjectStorage (job: Job) {
17 const payload = job.data as MoveObjectStoragePayload 19 const payload = job.data as MoveObjectStoragePayload
18 logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) 20 logger.info('Moving video %s in job %d.', payload.videoUUID, job.id)
@@ -20,26 +22,33 @@ export async function processMoveToObjectStorage (job: Job) {
20 const video = await VideoModel.loadWithFiles(payload.videoUUID) 22 const video = await VideoModel.loadWithFiles(payload.videoUUID)
21 // No video, maybe deleted? 23 // No video, maybe deleted?
22 if (!video) { 24 if (!video) {
23 logger.info('Can\'t process job %d, video does not exist.', job.id) 25 logger.info('Can\'t process job %d, video does not exist.', job.id, lTagsBase(payload.videoUUID))
24 return undefined 26 return undefined
25 } 27 }
26 28
29 const lTags = lTagsBase(video.uuid, video.url)
30
27 try { 31 try {
28 if (video.VideoFiles) { 32 if (video.VideoFiles) {
33 logger.debug('Moving %d webtorrent files for video %s.', video.VideoFiles.length, video.uuid, lTags)
34
29 await moveWebTorrentFiles(video) 35 await moveWebTorrentFiles(video)
30 } 36 }
31 37
32 if (video.VideoStreamingPlaylists) { 38 if (video.VideoStreamingPlaylists) {
39 logger.debug('Moving HLS playlist of %s.', video.uuid)
40
33 await moveHLSFiles(video) 41 await moveHLSFiles(video)
34 } 42 }
35 43
36 const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove') 44 const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove')
37 if (pendingMove === 0) { 45 if (pendingMove === 0) {
38 logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id) 46 logger.info('Running cleanup after moving files to object storage (video %s in job %d)', video.uuid, job.id, lTags)
47
39 await doAfterLastJob(video, payload.isNewVideo) 48 await doAfterLastJob(video, payload.isNewVideo)
40 } 49 }
41 } catch (err) { 50 } catch (err) {
42 logger.error('Cannot move video %s to object storage.', video.url, { err }) 51 logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTags })
43 52
44 await moveToFailedMoveToObjectStorageState(video) 53 await moveToFailedMoveToObjectStorageState(video)
45 await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove') 54 await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove')