From 679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 6 Aug 2021 13:35:25 +0200 Subject: Improve target bitrate calculation --- .../initializers/migrations/0075-video-resolutions.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'server/initializers/migrations/0075-video-resolutions.ts') diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts index 496125adb..6e8e47acb 100644 --- a/server/initializers/migrations/0075-video-resolutions.ts +++ b/server/initializers/migrations/0075-video-resolutions.ts @@ -27,17 +27,15 @@ function up (utils: { const ext = matches[2] const p = getVideoFileResolution(join(videoFileDir, videoFile)) - .then(height => { + .then(async ({ resolution }) => { const oldTorrentName = uuid + '.torrent' - const newTorrentName = uuid + '-' + height + '.torrent' - return rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height) - }) - .then(height => { - const newVideoFileName = uuid + '-' + height + '.' + ext - return rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height) - }) - .then(height => { - const query = 'UPDATE "VideoFiles" SET "resolution" = ' + height + + const newTorrentName = uuid + '-' + resolution + '.torrent' + await rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => resolution) + + const newVideoFileName = uuid + '-' + resolution + '.' + ext + await rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => resolution) + + const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution + ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')' return utils.sequelize.query(query) }) -- cgit v1.2.3