diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-09 11:52:41 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-11-09 15:00:21 +0100 |
commit | 221ee1adc916684d4881d2a9c4c01954dcde986e (patch) | |
tree | f456a3f3e1fcc2d8dbd3cc6f0d72a4cb2cbbadc2 /server | |
parent | 4e29f4fe23b413cc8c55ac0d8373f36bcd60b47a (diff) | |
download | PeerTube-221ee1adc916684d4881d2a9c4c01954dcde986e.tar.gz PeerTube-221ee1adc916684d4881d2a9c4c01954dcde986e.tar.zst PeerTube-221ee1adc916684d4881d2a9c4c01954dcde986e.zip |
Add transcoding fail message in client
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/job-queue/handlers/video-file-import.ts | 14 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 7 | ||||
-rw-r--r-- | server/lib/video-state.ts | 8 | ||||
-rw-r--r-- | server/tests/cli/create-import-video-file-job.ts | 6 |
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' | |||
7 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' | 7 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' |
8 | import { addMoveToObjectStorageJob } from '@server/lib/video' | 8 | import { addMoveToObjectStorageJob } from '@server/lib/video' |
9 | import { VideoPathManager } from '@server/lib/video-path-manager' | 9 | import { VideoPathManager } from '@server/lib/video-path-manager' |
10 | import { UserModel } from '@server/models/user/user' | ||
11 | import { MVideoFullLight } from '@server/types/models' | 10 | import { MVideoFullLight } from '@server/types/models' |
12 | import { VideoFileImportPayload, VideoStorage } from '@shared/models' | 11 | import { VideoFileImportPayload, VideoStorage } from '@shared/models' |
13 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' | 12 | import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffprobe-utils' |
14 | import { logger } from '../../../helpers/logger' | 13 | import { logger } from '../../../helpers/logger' |
15 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
16 | import { VideoFileModel } from '../../../models/video/video-file' | 15 | import { VideoFileModel } from '../../../models/video/video-file' |
17 | import { createHlsJobIfEnabled } from './video-transcoding' | ||
18 | 16 | ||
19 | async function processVideoFileImport (job: Job) { | 17 | async 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' | |||
2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' | 2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' |
3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' | 3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' |
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | 4 | import { VideoPathManager } from '@server/lib/video-path-manager' |
5 | import { moveToFailedState, moveToNextState } from '@server/lib/video-state' | 5 | import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state' |
6 | import { UserModel } from '@server/models/user/user' | 6 | import { UserModel } from '@server/models/user/user' |
7 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' | 7 | import { VideoJobInfoModel } from '@server/models/video/video-job-info' |
8 | import { MUser, MUserId, MVideo, MVideoFullLight, MVideoWithFile } from '@server/types/models' | 8 | import { 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 | ||
82 | function moveToFailedState (video: MVideoFullLight) { | 82 | function 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) { | |||
90 | export { | 88 | export { |
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' |
17 | import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models' | 17 | import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const 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) |