Fix video job error when video has been deleted

This commit is contained in:
Chocobozzz 2022-10-10 14:51:11 +02:00
parent 1a3b53de6f
commit 52d6c2e0bf
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 4 additions and 2 deletions

View File

@ -84,7 +84,7 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo
static async decrease (videoUUID: string, column: VideoJobInfoColumnType): Promise<number> {
const options = { type: QueryTypes.SELECT as QueryTypes.SELECT, bind: { videoUUID } }
const [ { pendingMove } ] = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
const result = await VideoJobInfoModel.sequelize.query<{ pendingMove: number }>(`
UPDATE
"videoJobInfo"
SET
@ -97,7 +97,9 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo
"${column}";
`, options)
return pendingMove
if (result.length === 0) return undefined
return result[0].pendingMove
}
static async abortAllTasks (videoUUID: string, column: VideoJobInfoColumnType): Promise<void> {