aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-16 18:21:36 +0100
committerChocobozzz <me@florianbigard.com>2022-03-16 18:35:05 +0100
commit52fe4b671a20c37ae46cf88d175dd16cddfc4de7 (patch)
tree41339d83393d9e7d3ca05b66aeb9bd79c6019b2c
parentf012319a644fe8d9d33f2f567fa828442a3b39fd (diff)
downloadPeerTube-52fe4b671a20c37ae46cf88d175dd16cddfc4de7.tar.gz
PeerTube-52fe4b671a20c37ae46cf88d175dd16cddfc4de7.tar.zst
PeerTube-52fe4b671a20c37ae46cf88d175dd16cddfc4de7.zip
Fix torrent creation
-rw-r--r--server/lib/job-queue/handlers/manage-video-torrent.ts4
-rw-r--r--server/tests/api/check-params/video-editor.ts5
-rw-r--r--server/tests/api/server/jobs.ts9
3 files changed, 13 insertions, 5 deletions
diff --git a/server/lib/job-queue/handlers/manage-video-torrent.ts b/server/lib/job-queue/handlers/manage-video-torrent.ts
index 5cb4287e1..dfd4e6140 100644
--- a/server/lib/job-queue/handlers/manage-video-torrent.ts
+++ b/server/lib/job-queue/handlers/manage-video-torrent.ts
@@ -28,6 +28,8 @@ async function doCreateAction (payload: ManageVideoTorrentPayload & { action: 'c
28 loadFileOrLog(payload.videoFileId) 28 loadFileOrLog(payload.videoFileId)
29 ]) 29 ])
30 30
31 if (!video || !file) return
32
31 await createTorrentAndSetInfoHash(video, file) 33 await createTorrentAndSetInfoHash(video, file)
32 34
33 // Refresh videoFile because the createTorrentAndSetInfoHash could be long 35 // Refresh videoFile because the createTorrentAndSetInfoHash could be long
@@ -48,6 +50,8 @@ async function doUpdateMetadataAction (payload: ManageVideoTorrentPayload & { ac
48 loadFileOrLog(payload.videoFileId) 50 loadFileOrLog(payload.videoFileId)
49 ]) 51 ])
50 52
53 if ((!video && !streamingPlaylist) || !file) return
54
51 await updateTorrentMetadata(video || streamingPlaylist, file) 55 await updateTorrentMetadata(video || streamingPlaylist, file)
52 56
53 await file.save() 57 await file.save()
diff --git a/server/tests/api/check-params/video-editor.ts b/server/tests/api/check-params/video-editor.ts
index db284a3cc..1fd22c497 100644
--- a/server/tests/api/check-params/video-editor.ts
+++ b/server/tests/api/check-params/video-editor.ts
@@ -122,10 +122,11 @@ describe('Test video editor API validator', function () {
122 }) 122 })
123 123
124 it('Should fail with an already in transcoding state video', async function () { 124 it('Should fail with an already in transcoding state video', async function () {
125 await server.jobs.pauseJobQueue()
126
127 const { uuid } = await server.videos.quickUpload({ name: 'transcoded video' }) 125 const { uuid } = await server.videos.quickUpload({ name: 'transcoded video' })
128 126
127 await server.jobs.pauseJobQueue()
128 await server.videos.runTranscoding({ videoId: uuid, transcodingType: 'hls' })
129
129 await command.createEditionTasks({ 130 await command.createEditionTasks({
130 videoId: uuid, 131 videoId: uuid,
131 tasks: VideoEditorCommand.getComplexTask(), 132 tasks: VideoEditorCommand.getComplexTask(),
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index bd8ffe188..6cc88a123 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -12,6 +12,7 @@ import {
12 waitJobs 12 waitJobs
13} from '@shared/server-commands' 13} from '@shared/server-commands'
14import { wait } from '@shared/core-utils' 14import { wait } from '@shared/core-utils'
15import { uuid } from 'short-uuid'
15 16
16const expect = chai.expect 17const expect = chai.expect
17 18
@@ -95,14 +96,16 @@ describe('Test jobs', function () {
95 it('Should pause the job queue', async function () { 96 it('Should pause the job queue', async function () {
96 this.timeout(120000) 97 this.timeout(120000)
97 98
98 await servers[1].jobs.pauseJobQueue() 99 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video2' } })
100 await waitJobs(servers)
99 101
100 await servers[1].videos.upload({ attributes: { name: 'video2' } }) 102 await servers[1].jobs.pauseJobQueue()
103 await servers[1].videos.runTranscoding({ videoId: uuid, transcodingType: 'hls' })
101 104
102 await wait(5000) 105 await wait(5000)
103 106
104 const body = await servers[1].jobs.list({ state: 'waiting', jobType: 'video-transcoding' }) 107 const body = await servers[1].jobs.list({ state: 'waiting', jobType: 'video-transcoding' })
105 expect(body.data).to.have.lengthOf(1) 108 expect(body.data).to.have.lengthOf(4)
106 }) 109 })
107 110
108 it('Should resume the job queue', async function () { 111 it('Should resume the job queue', async function () {