aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/remote
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/remote')
-rw-r--r--server/controllers/api/remote/videos.ts42
1 files changed, 40 insertions, 2 deletions
diff --git a/server/controllers/api/remote/videos.ts b/server/controllers/api/remote/videos.ts
index 30771d8c4..e7edff606 100644
--- a/server/controllers/api/remote/videos.ts
+++ b/server/controllers/api/remote/videos.ts
@@ -258,8 +258,6 @@ function addRemoteVideo (videoToCreateData: RemoteVideoCreateData, fromPod: PodI
258 const videoData = { 258 const videoData = {
259 name: videoToCreateData.name, 259 name: videoToCreateData.name,
260 uuid: videoToCreateData.uuid, 260 uuid: videoToCreateData.uuid,
261 extname: videoToCreateData.extname,
262 infoHash: videoToCreateData.infoHash,
263 category: videoToCreateData.category, 261 category: videoToCreateData.category,
264 licence: videoToCreateData.licence, 262 licence: videoToCreateData.licence,
265 language: videoToCreateData.language, 263 language: videoToCreateData.language,
@@ -290,6 +288,26 @@ function addRemoteVideo (videoToCreateData: RemoteVideoCreateData, fromPod: PodI
290 return video.save(options).then(videoCreated => ({ tagInstances, videoCreated })) 288 return video.save(options).then(videoCreated => ({ tagInstances, videoCreated }))
291 }) 289 })
292 .then(({ tagInstances, videoCreated }) => { 290 .then(({ tagInstances, videoCreated }) => {
291 const tasks = []
292 const options = {
293 transaction: t
294 }
295
296 videoToCreateData.files.forEach(fileData => {
297 const videoFileInstance = db.VideoFile.build({
298 extname: fileData.extname,
299 infoHash: fileData.infoHash,
300 resolution: fileData.resolution,
301 size: fileData.size,
302 videoId: videoCreated.id
303 })
304
305 tasks.push(videoFileInstance.save(options))
306 })
307
308 return Promise.all(tasks).then(() => ({ tagInstances, videoCreated }))
309 })
310 .then(({ tagInstances, videoCreated }) => {
293 const options = { 311 const options = {
294 transaction: t 312 transaction: t
295 } 313 }
@@ -344,6 +362,26 @@ function updateRemoteVideo (videoAttributesToUpdate: RemoteVideoUpdateData, from
344 362
345 return videoInstance.save(options).then(() => ({ videoInstance, tagInstances })) 363 return videoInstance.save(options).then(() => ({ videoInstance, tagInstances }))
346 }) 364 })
365 .then(({ tagInstances, videoInstance }) => {
366 const tasks = []
367 const options = {
368 transaction: t
369 }
370
371 videoAttributesToUpdate.files.forEach(fileData => {
372 const videoFileInstance = db.VideoFile.build({
373 extname: fileData.extname,
374 infoHash: fileData.infoHash,
375 resolution: fileData.resolution,
376 size: fileData.size,
377 videoId: videoInstance.id
378 })
379
380 tasks.push(videoFileInstance.save(options))
381 })
382
383 return Promise.all(tasks).then(() => ({ tagInstances, videoInstance }))
384 })
347 .then(({ videoInstance, tagInstances }) => { 385 .then(({ videoInstance, tagInstances }) => {
348 const options = { transaction: t } 386 const options = { transaction: t }
349 387