diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-25 10:21:38 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-25 13:50:48 +0200 |
commit | 6b738c7a31591a83fdcd9c78b6b1f98e543c378b (patch) | |
tree | db771d0e99e9ff27570885fe2a6f58a7c1948fbc /server/models/video/video.ts | |
parent | 48dce1c90dff4e90a4bcffefaecf157336cf904b (diff) | |
download | PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.gz PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.tar.zst PeerTube-6b738c7a31591a83fdcd9c78b6b1f98e543c378b.zip |
Video channel API routes refractor
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 7ababbf23..f23fac2ab 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -430,7 +430,7 @@ export class VideoModel extends Model<VideoModel> { | |||
430 | foreignKey: { | 430 | foreignKey: { |
431 | allowNull: true | 431 | allowNull: true |
432 | }, | 432 | }, |
433 | onDelete: 'cascade' | 433 | hooks: true |
434 | }) | 434 | }) |
435 | VideoChannel: VideoChannelModel | 435 | VideoChannel: VideoChannelModel |
436 | 436 | ||
@@ -510,10 +510,12 @@ export class VideoModel extends Model<VideoModel> { | |||
510 | return undefined | 510 | return undefined |
511 | } | 511 | } |
512 | 512 | ||
513 | @AfterDestroy | 513 | @BeforeDestroy |
514 | static async removeFilesAndSendDelete (instance: VideoModel) { | 514 | static async removeFilesAndSendDelete (instance: VideoModel) { |
515 | const tasks: Promise<any>[] = [] | 515 | const tasks: Promise<any>[] = [] |
516 | 516 | ||
517 | logger.debug('Removing files of video %s.', instance.url) | ||
518 | |||
517 | tasks.push(instance.removeThumbnail()) | 519 | tasks.push(instance.removeThumbnail()) |
518 | 520 | ||
519 | if (instance.isOwned()) { | 521 | if (instance.isOwned()) { |
@@ -530,10 +532,13 @@ export class VideoModel extends Model<VideoModel> { | |||
530 | }) | 532 | }) |
531 | } | 533 | } |
532 | 534 | ||
533 | return Promise.all(tasks) | 535 | // Do not wait video deletion because we could be in a transaction |
536 | Promise.all(tasks) | ||
534 | .catch(err => { | 537 | .catch(err => { |
535 | logger.error('Some errors when removing files of video %s in after destroy hook.', instance.uuid, { err }) | 538 | logger.error('Some errors when removing files of video %s in after destroy hook.', instance.uuid, { err }) |
536 | }) | 539 | }) |
540 | |||
541 | return undefined | ||
537 | } | 542 | } |
538 | 543 | ||
539 | static list () { | 544 | static list () { |