diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/videos.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index b1e7f20b9..34685b6b1 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -205,7 +205,7 @@ async function updateVideoFromAP (options: { | |||
205 | let videoFieldsSave: any | 205 | let videoFieldsSave: any |
206 | 206 | ||
207 | try { | 207 | try { |
208 | const updatedVideo: VideoModel = await sequelizeTypescript.transaction(async t => { | 208 | await sequelizeTypescript.transaction(async t => { |
209 | const sequelizeOptions = { | 209 | const sequelizeOptions = { |
210 | transaction: t | 210 | transaction: t |
211 | } | 211 | } |
@@ -256,8 +256,12 @@ async function updateVideoFromAP (options: { | |||
256 | await Promise.all(destroyTasks) | 256 | await Promise.all(destroyTasks) |
257 | 257 | ||
258 | // Update or add other one | 258 | // Update or add other one |
259 | const upsertTasks = videoFileAttributes.map(a => VideoFileModel.upsert(a, sequelizeOptions)) | 259 | const upsertTasks = videoFileAttributes.map(a => { |
260 | await Promise.all(upsertTasks) | 260 | return VideoFileModel.upsert<VideoFileModel>(a, { returning: true, transaction: t }) |
261 | .then(([ file ]) => file) | ||
262 | }) | ||
263 | |||
264 | options.video.VideoFiles = await Promise.all(upsertTasks) | ||
261 | } | 265 | } |
262 | 266 | ||
263 | { | 267 | { |
@@ -274,13 +278,11 @@ async function updateVideoFromAP (options: { | |||
274 | const videoCaptionsPromises = options.videoObject.subtitleLanguage.map(c => { | 278 | const videoCaptionsPromises = options.videoObject.subtitleLanguage.map(c => { |
275 | return VideoCaptionModel.insertOrReplaceLanguage(options.video.id, c.identifier, t) | 279 | return VideoCaptionModel.insertOrReplaceLanguage(options.video.id, c.identifier, t) |
276 | }) | 280 | }) |
277 | await Promise.all(videoCaptionsPromises) | 281 | options.video.VideoCaptions = await Promise.all(videoCaptionsPromises) |
278 | } | 282 | } |
279 | }) | 283 | }) |
280 | 284 | ||
281 | logger.info('Remote video with uuid %s updated', options.videoObject.uuid) | 285 | logger.info('Remote video with uuid %s updated', options.videoObject.uuid) |
282 | |||
283 | return updatedVideo | ||
284 | } catch (err) { | 286 | } catch (err) { |
285 | if (options.video !== undefined && videoFieldsSave !== undefined) { | 287 | if (options.video !== undefined && videoFieldsSave !== undefined) { |
286 | resetSequelizeInstance(options.video, videoFieldsSave) | 288 | resetSequelizeInstance(options.video, videoFieldsSave) |
@@ -392,12 +394,10 @@ async function refreshVideoIfNeeded (options: { | |||
392 | channel: channelActor.VideoChannel, | 394 | channel: channelActor.VideoChannel, |
393 | updateViews: options.refreshViews | 395 | updateViews: options.refreshViews |
394 | } | 396 | } |
395 | const videoUpdated = await retryTransactionWrapper(updateVideoFromAP, updateOptions) | 397 | await retryTransactionWrapper(updateVideoFromAP, updateOptions) |
396 | await syncVideoExternalAttributes(videoUpdated, videoObject, options.syncParam) | 398 | await syncVideoExternalAttributes(video, videoObject, options.syncParam) |
397 | |||
398 | return videoUpdated | ||
399 | } catch (err) { | 399 | } catch (err) { |
400 | logger.warn('Cannot refresh video.', { err }) | 400 | logger.warn('Cannot refresh video %s.', options.video.url, { err }) |
401 | return video | 401 | return video |
402 | } | 402 | } |
403 | } | 403 | } |