aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/services.ts3
-rw-r--r--server/models/video/video.ts6
-rw-r--r--server/tests/cli/create-import-video-file-job.ts32
3 files changed, 33 insertions, 8 deletions
diff --git a/server/controllers/services.ts b/server/controllers/services.ts
index 1f82db9c4..1dd8e28e5 100644
--- a/server/controllers/services.ts
+++ b/server/controllers/services.ts
@@ -45,7 +45,8 @@ function generateOEmbed (req: express.Request, res: express.Response, next: expr
45 thumbnailUrl = undefined 45 thumbnailUrl = undefined
46 } 46 }
47 47
48 const html = `<iframe width="${embedWidth}" height="${embedHeight}" sandbox="allow-same-origin allow-scripts" src="${embedUrl}" frameborder="0" allowfullscreen></iframe>` 48 const html = `<iframe width="${embedWidth}" height="${embedHeight}" sandbox="allow-same-origin allow-scripts" ` +
49 `src="${embedUrl}" frameborder="0" allowfullscreen></iframe>`
49 50
50 const json: any = { 51 const json: any = {
51 type: 'video', 52 type: 'video',
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index faa6f3f9b..1cb1e6798 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1325,9 +1325,6 @@ export class VideoModel extends Model<VideoModel> {
1325 videoId: this.id 1325 videoId: this.id
1326 }) 1326 })
1327 1327
1328 const outputPath = this.getVideoFilePath(updatedVideoFile)
1329 await copyFilePromise(inputFilePath, outputPath)
1330
1331 const currentVideoFile = this.VideoFiles.find(videoFile => videoFile.resolution === updatedVideoFile.resolution) 1328 const currentVideoFile = this.VideoFiles.find(videoFile => videoFile.resolution === updatedVideoFile.resolution)
1332 1329
1333 if (currentVideoFile) { 1330 if (currentVideoFile) {
@@ -1344,6 +1341,9 @@ export class VideoModel extends Model<VideoModel> {
1344 updatedVideoFile = currentVideoFile 1341 updatedVideoFile = currentVideoFile
1345 } 1342 }
1346 1343
1344 const outputPath = this.getVideoFilePath(updatedVideoFile)
1345 await copyFilePromise(inputFilePath, outputPath)
1346
1347 await this.createTorrentAndSetInfoHash(updatedVideoFile) 1347 await this.createTorrentAndSetInfoHash(updatedVideoFile)
1348 1348
1349 await updatedVideoFile.save() 1349 await updatedVideoFile.save()
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 372c7e517..1472e60f6 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -73,22 +73,22 @@ describe('Test create import video jobs', function () {
73 73
74 expect(videoDetail.files).to.have.lengthOf(2) 74 expect(videoDetail.files).to.have.lengthOf(2)
75 const [originalVideo, transcodedVideo] = videoDetail.files 75 const [originalVideo, transcodedVideo] = videoDetail.files
76 assertVideoProperties(originalVideo, 720, 'webm') 76 assertVideoProperties(originalVideo, 720, 'webm', 218910)
77 assertVideoProperties(transcodedVideo, 480, 'webm') 77 assertVideoProperties(transcodedVideo, 480, 'webm', 69217)
78 78
79 if (!magnetUri) magnetUri = transcodedVideo.magnetUri 79 if (!magnetUri) magnetUri = transcodedVideo.magnetUri
80 else expect(transcodedVideo.magnetUri).to.equal(magnetUri) 80 else expect(transcodedVideo.magnetUri).to.equal(magnetUri)
81 } 81 }
82 }) 82 })
83 83
84 it('Should run a import job on video 2 with the same resolution', async function () { 84 it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
85 const env = getEnvCli(servers[1]) 85 const env = getEnvCli(servers[1])
86 await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) 86 await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`)
87 87
88 await wait(30000) 88 await wait(30000)
89 89
90 let magnetUri: string 90 let magnetUri: string
91 for (const server of servers.reverse()) { 91 for (const server of servers) {
92 const { data: videos } = (await getVideosList(server.url)).body 92 const { data: videos } = (await getVideosList(server.url)).body
93 expect(videos).to.have.lengthOf(2) 93 expect(videos).to.have.lengthOf(2)
94 94
@@ -107,6 +107,30 @@ describe('Test create import video jobs', function () {
107 } 107 }
108 }) 108 })
109 109
110 it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
111 const env = getEnvCli(servers[0])
112 await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`)
113
114 await wait(30000)
115
116 let magnetUri: string
117 for (const server of servers) {
118 const { data: videos } = (await getVideosList(server.url)).body
119 expect(videos).to.have.lengthOf(2)
120
121 const video = videos.find(({ uuid }) => uuid === video1UUID)
122 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body
123
124 expect(videoDetail.files).to.have.lengthOf(2)
125 const [ video720, video480 ] = videoDetail.files
126 assertVideoProperties(video720, 720, 'webm', 942961)
127 assertVideoProperties(video480, 480, 'webm', 69217)
128
129 if (!magnetUri) magnetUri = video720.magnetUri
130 else expect(video720.magnetUri).to.equal(magnetUri)
131 }
132 })
133
110 after(async function () { 134 after(async function () {
111 killallServers(servers) 135 killallServers(servers)
112 136