aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/job-queue/handlers/video-file-import.ts14
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts7
-rw-r--r--server/lib/video-state.ts8
-rw-r--r--server/tests/cli/create-import-video-file-job.ts6
4 files changed, 10 insertions, 25 deletions
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts
index e6c918e6c..47ae10a66 100644
--- a/server/lib/job-queue/handlers/video-file-import.ts
+++ b/server/lib/job-queue/handlers/video-file-import.ts
@@ -7,14 +7,12 @@ import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
7import { generateWebTorrentVideoFilename } from '@server/lib/paths' 7import { generateWebTorrentVideoFilename } from '@server/lib/paths'
8import { addMoveToObjectStorageJob } from '@server/lib/video' 8import { addMoveToObjectStorageJob } from '@server/lib/video'
9import { VideoPathManager } from '@server/lib/video-path-manager' 9import { VideoPathManager } from '@server/lib/video-path-manager'
10import { UserModel } from '@server/models/user/user'
11import { MVideoFullLight } from '@server/types/models' 10import { MVideoFullLight } from '@server/types/models'
12import { VideoFileImportPayload, VideoStorage } from '@shared/models' 11import { VideoFileImportPayload, VideoStorage } from '@shared/models'
13import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' 12import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils'
14import { logger } from '../../../helpers/logger' 13import { logger } from '../../../helpers/logger'
15import { VideoModel } from '../../../models/video/video' 14import { VideoModel } from '../../../models/video/video'
16import { VideoFileModel } from '../../../models/video/video-file' 15import { VideoFileModel } from '../../../models/video/video-file'
17import { createHlsJobIfEnabled } from './video-transcoding'
18 16
19async function processVideoFileImport (job: Job) { 17async function processVideoFileImport (job: Job) {
20 const payload = job.data as VideoFileImportPayload 18 const payload = job.data as VideoFileImportPayload
@@ -27,20 +25,8 @@ async function processVideoFileImport (job: Job) {
27 return undefined 25 return undefined
28 } 26 }
29 27
30 const data = await getVideoFileResolution(payload.filePath)
31
32 await updateVideoFile(video, payload.filePath) 28 await updateVideoFile(video, payload.filePath)
33 29
34 const user = await UserModel.loadByChannelActorId(video.VideoChannel.actorId)
35
36 await createHlsJobIfEnabled(user, {
37 videoUUID: video.uuid,
38 resolution: data.resolution,
39 isPortraitMode: data.isPortraitMode,
40 copyCodecs: true,
41 isMaxQuality: false
42 })
43
44 if (CONFIG.OBJECT_STORAGE.ENABLED) { 30 if (CONFIG.OBJECT_STORAGE.ENABLED) {
45 await addMoveToObjectStorageJob(video) 31 await addMoveToObjectStorageJob(video)
46 } else { 32 } else {
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index b280a1cc9..0143cd02a 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -2,7 +2,7 @@ import { Job } from 'bull'
2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' 2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' 3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
4import { VideoPathManager } from '@server/lib/video-path-manager' 4import { VideoPathManager } from '@server/lib/video-path-manager'
5import { moveToFailedState, moveToNextState } from '@server/lib/video-state' 5import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state'
6import { UserModel } from '@server/models/user/user' 6import { UserModel } from '@server/models/user/user'
7import { VideoJobInfoModel } from '@server/models/video/video-job-info' 7import { VideoJobInfoModel } from '@server/models/video/video-job-info'
8import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' 8import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models'
@@ -52,14 +52,15 @@ async function processVideoTranscoding (job: Job) {
52 const handler = handlers[payload.type] 52 const handler = handlers[payload.type]
53 53
54 if (!handler) { 54 if (!handler) {
55 await moveToFailedState(video) 55 await moveToFailedTranscodingState(video)
56
56 throw new Error('Cannot find transcoding handler for ' + payload.type) 57 throw new Error('Cannot find transcoding handler for ' + payload.type)
57 } 58 }
58 59
59 try { 60 try {
60 await handler(job, payload, video, user) 61 await handler(job, payload, video, user)
61 } catch (error) { 62 } catch (error) {
62 await moveToFailedState(video) 63 await moveToFailedTranscodingState(video)
63 64
64 throw error 65 throw error
65 } 66 }
diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts
index 2260e90f5..0b51f5c6b 100644
--- a/server/lib/video-state.ts
+++ b/server/lib/video-state.ts
@@ -79,10 +79,8 @@ async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: b
79 } 79 }
80} 80}
81 81
82function moveToFailedState (video: MVideoFullLight) { 82function moveToFailedTranscodingState (video: MVideoFullLight) {
83 return sequelizeTypescript.transaction(async t => { 83 return video.setNewState(VideoState.TRANSCODING_FAILED, false, undefined)
84 await video.setNewState(VideoState.TRANSCODING_FAILED, false, t)
85 })
86} 84}
87 85
88// --------------------------------------------------------------------------- 86// ---------------------------------------------------------------------------
@@ -90,7 +88,7 @@ function moveToFailedState (video: MVideoFullLight) {
90export { 88export {
91 buildNextVideoState, 89 buildNextVideoState,
92 moveToExternalStorageState, 90 moveToExternalStorageState,
93 moveToFailedState, 91 moveToFailedTranscodingState,
94 moveToNextState 92 moveToNextState
95} 93}
96 94
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 01817216e..1e278bacc 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -14,7 +14,7 @@ import {
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 waitJobs 15 waitJobs
16} from '@shared/extra-utils' 16} from '@shared/extra-utils'
17import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models' 17import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'
18 18
19const expect = chai.expect 19const expect = chai.expect
20 20
@@ -100,7 +100,7 @@ function runTests (objectStorage: boolean) {
100 await waitJobs(servers) 100 await waitJobs(servers)
101 101
102 for (const server of servers) { 102 for (const server of servers) {
103 const { data: videos } = await server.videos.list() 103 const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE })
104 expect(videos).to.have.lengthOf(2) 104 expect(videos).to.have.lengthOf(2)
105 105
106 const video = videos.find(({ uuid }) => uuid === video2UUID) 106 const video = videos.find(({ uuid }) => uuid === video2UUID)
@@ -124,7 +124,7 @@ function runTests (objectStorage: boolean) {
124 await waitJobs(servers) 124 await waitJobs(servers)
125 125
126 for (const server of servers) { 126 for (const server of servers) {
127 const { data: videos } = await server.videos.list() 127 const { data: videos } = await server.videos.listWithToken({ include: VideoInclude.NOT_PUBLISHED_STATE })
128 expect(videos).to.have.lengthOf(2) 128 expect(videos).to.have.lengthOf(2)
129 129
130 const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId) 130 const video = videos.find(({ shortUUID }) => shortUUID === video1ShortId)