From 44d1f7f2e8119b8da6a11c3a7b9ef1dd5315d031 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Feb 2021 11:22:42 +0100 Subject: Painfully debug concurrent import jobs --- server/models/video/video-import.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server/models') diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts index f3ed651b2..8324166cc 100644 --- a/server/models/video/video-import.ts +++ b/server/models/video/video-import.ts @@ -21,6 +21,7 @@ import { CONSTRAINTS_FIELDS, VIDEO_IMPORT_STATES } from '../../initializers/cons import { UserModel } from '../account/user' import { getSort, throwIfNotValid } from '../utils' import { ScopeNames as VideoModelScopeNames, VideoModel } from './video' +import { afterCommitIfTransaction } from '@server/helpers/database-utils' @DefaultScope(() => ({ include: [ @@ -113,7 +114,7 @@ export class VideoImportModel extends Model { @AfterUpdate static deleteVideoIfFailed (instance: VideoImportModel, options) { if (instance.state === VideoImportState.FAILED) { - return instance.Video.destroy({ transaction: options.transaction }) + return afterCommitIfTransaction(options.transaction, () => instance.Video.destroy()) } return undefined -- cgit v1.2.3