From 62689b942b71cd1dd0d050c6ed05f884a0b325c2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Aug 2018 16:23:34 +0200 Subject: Correctly migrate to fs-extra --- server/controllers/api/videos/import.ts | 6 +++--- server/controllers/api/videos/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index b2f73fa48..44f15ef74 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts @@ -27,8 +27,8 @@ import { FilteredModelAttributes } from 'sequelize-typescript/lib/models/Model' import { VideoChannelModel } from '../../../models/video/video-channel' import * as Bluebird from 'bluebird' import * as parseTorrent from 'parse-torrent' -import { readFileBufferPromise, renamePromise } from '../../../helpers/core-utils' import { getSecureTorrentName } from '../../../helpers/utils' +import { readFile, rename } from 'fs-extra' const auditLogger = auditLoggerFactory('video-imports') const videoImportsRouter = express.Router() @@ -78,10 +78,10 @@ async function addTorrentImport (req: express.Request, res: express.Response, to // Rename the torrent to a secured name const newTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, getSecureTorrentName(torrentName)) - await renamePromise(torrentfile.path, newTorrentPath) + await rename(torrentfile.path, newTorrentPath) torrentfile.path = newTorrentPath - const buf = await readFileBufferPromise(torrentfile.path) + const buf = await readFile(torrentfile.path) const parsedTorrent = parseTorrent(buf) videoName = isArray(parsedTorrent.name) ? parsedTorrent.name[ 0 ] : parsedTorrent.name as string diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index e973aa43f..a86cf4f99 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -1,7 +1,6 @@ import * as express from 'express' import { extname, join } from 'path' import { VideoCreate, VideoPrivacy, VideoState, VideoUpdate } from '../../../../shared' -import { renamePromise } from '../../../helpers/core-utils' import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { processImage } from '../../../helpers/image-utils' import { logger } from '../../../helpers/logger' @@ -56,6 +55,7 @@ import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-u import { videoCaptionsRouter } from './captions' import { videoImportsRouter } from './import' import { resetSequelizeInstance } from '../../../helpers/database-utils' +import { rename } from 'fs-extra' const auditLogger = auditLoggerFactory('videos') const videosRouter = express.Router() @@ -194,7 +194,7 @@ async function addVideo (req: express.Request, res: express.Response) { // Move physical file const videoDir = CONFIG.STORAGE.VIDEOS_DIR const destination = join(videoDir, video.getVideoFilename(videoFile)) - await renamePromise(videoPhysicalFile.path, destination) + await rename(videoPhysicalFile.path, destination) // This is important in case if there is another attempt in the retry process videoPhysicalFile.filename = video.getVideoFilename(videoFile) videoPhysicalFile.path = destination -- cgit v1.2.3