Fix video removing when it is corrupted
authorChocobozzz <florian.bigard@gmail.com>
Thu, 19 Oct 2017 07:28:35 +0000 (09:28 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 19 Oct 2017 07:28:35 +0000 (09:28 +0200)
server/models/video/video.ts

index fb18a485a4ed0bc1a5359761f434436469a6009e..4bd8eb98f5221a529c50b3165511c62add0623e0 100644 (file)
@@ -334,12 +334,15 @@ function afterDestroy (video: VideoInstance, options: { transaction: Sequelize.T
 
     // Remove physical files and torrents
     video.VideoFiles.forEach(file => {
-      video.removeFile(file),
-      video.removeTorrent(file)
+      tasks.push(video.removeFile(file))
+      tasks.push(video.removeTorrent(file))
     })
   }
 
   return Promise.all(tasks)
+    .catch(err => {
+      logger.error('Some errors when removing files of video %d in after destroy hook.', video.uuid, err)
+    })
 }
 
 getOriginalFile = function (this: VideoInstance) {