aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/captions-utils.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-27 16:23:34 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 16:23:34 +0200
commit62689b942b71cd1dd0d050c6ed05f884a0b325c2 (patch)
treec45c35d35d7a3e32621fba06edc63646930c8efd /server/helpers/captions-utils.ts
parent84b6dbcc6e8654f39ec798905e1151ba915cd1aa (diff)
downloadPeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.gz
PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.zst
PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.zip
Correctly migrate to fs-extra
Diffstat (limited to 'server/helpers/captions-utils.ts')
-rw-r--r--server/helpers/captions-utils.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts
index 20c9fe5aa..660dce65c 100644
--- a/server/helpers/captions-utils.ts
+++ b/server/helpers/captions-utils.ts
@@ -1,9 +1,8 @@
1import { renamePromise, unlinkPromise } from './core-utils'
2import { join } from 'path' 1import { join } from 'path'
3import { CONFIG } from '../initializers' 2import { CONFIG } from '../initializers'
4import { VideoCaptionModel } from '../models/video/video-caption' 3import { VideoCaptionModel } from '../models/video/video-caption'
5import * as srt2vtt from 'srt-to-vtt' 4import * as srt2vtt from 'srt-to-vtt'
6import { createReadStream, createWriteStream } from 'fs-extra' 5import { createReadStream, createWriteStream, remove, rename } from 'fs-extra'
7 6
8async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) { 7async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: VideoCaptionModel) {
9 const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR 8 const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
@@ -12,9 +11,9 @@ async function moveAndProcessCaptionFile (physicalFile: { filename: string, path
12 // Convert this srt file to vtt 11 // Convert this srt file to vtt
13 if (physicalFile.path.endsWith('.srt')) { 12 if (physicalFile.path.endsWith('.srt')) {
14 await convertSrtToVtt(physicalFile.path, destination) 13 await convertSrtToVtt(physicalFile.path, destination)
15 await unlinkPromise(physicalFile.path) 14 await remove(physicalFile.path)
16 } else { // Just move the vtt file 15 } else { // Just move the vtt file
17 await renamePromise(physicalFile.path, destination) 16 await rename(physicalFile.path, destination)
18 } 17 }
19 18
20 // This is important in case if there is another attempt in the retry process 19 // This is important in case if there is another attempt in the retry process