]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-caption.ts
Add user adminFlags
[github/Chocobozzz/PeerTube.git] / server / models / video / video-caption.ts
index 3593646a2ca1a857ed45ad355aee1a5ea9b1f4c6..f2dbbfde82821570aa443bc67d5711e4ec66839f 100644 (file)
@@ -16,10 +16,11 @@ import { throwIfNotValid } from '../utils'
 import { VideoModel } from './video'
 import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
 import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
-import { CONFIG, STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers'
+import { STATIC_PATHS, VIDEO_LANGUAGES } from '../../initializers/constants'
 import { join } from 'path'
 import { logger } from '../../helpers/logger'
-import { unlinkPromise } from '../../helpers/core-utils'
+import { remove } from 'fs-extra'
+import { CONFIG } from '../../initializers/config'
 
 export enum ScopeNames {
   WITH_VIDEO_UUID_AND_REMOTE = 'WITH_VIDEO_UUID_AND_REMOTE'
@@ -120,7 +121,8 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> {
       language
     }
 
-    return VideoCaptionModel.upsert(values, { transaction })
+    return VideoCaptionModel.upsert<VideoCaptionModel>(values, { transaction, returning: true })
+      .then(([ caption ]) => caption)
   }
 
   static listVideoCaptions (videoId: number) {
@@ -172,6 +174,6 @@ export class VideoCaptionModel extends Model<VideoCaptionModel> {
   }
 
   removeCaptionFile () {
-    return unlinkPromise(CONFIG.STORAGE.CAPTIONS_DIR + this.getCaptionName())
+    return remove(CONFIG.STORAGE.CAPTIONS_DIR + this.getCaptionName())
   }
 }