X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fmigrations%2F0075-video-resolutions.ts;h=26a188e5e8f834ac0e05f64a6ebea89cb825768e;hb=2c3abc4fa796555eb7d25f416c4f41ab3e3ad8ca;hp=e7d8a287609dc8e8ebf893d13c872652d5439c95;hpb=571389d43b8fc8aaf27e77c06f19b320b08dbbc9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts index e7d8a2876..26a188e5e 100644 --- a/server/initializers/migrations/0075-video-resolutions.ts +++ b/server/initializers/migrations/0075-video-resolutions.ts @@ -1,9 +1,8 @@ import * as Sequelize from 'sequelize' import { join } from 'path' - -import { readdirPromise, renamePromise } from '../../helpers/core-utils' import { CONFIG } from '../../initializers/constants' -import { getVideoFileHeight } from '../../helpers/ffmpeg-utils' +import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' +import { readdir, rename } from 'fs-extra' function up (utils: { transaction: Sequelize.Transaction, @@ -14,7 +13,7 @@ function up (utils: { const torrentDir = CONFIG.STORAGE.TORRENTS_DIR const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR - return readdirPromise(videoFileDir) + return readdir(videoFileDir) .then(videoFiles => { const tasks: Promise[] = [] for (const videoFile of videoFiles) { @@ -27,15 +26,15 @@ function up (utils: { const uuid = matches[1] const ext = matches[2] - const p = getVideoFileHeight(join(videoFileDir, videoFile)) + const p = getVideoFileResolution(join(videoFileDir, videoFile)) .then(height => { const oldTorrentName = uuid + '.torrent' const newTorrentName = uuid + '-' + height + '.torrent' - return renamePromise(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height) + return rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height) }) .then(height => { const newVideoFileName = uuid + '-' + height + '.' + ext - return renamePromise(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height) + return rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height) }) .then(height => { const query = 'UPDATE "VideoFiles" SET "resolution" = ' + height +