X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fmigrations%2F0075-video-resolutions.ts;h=6e8e47acbf04ef7d9ea286f99185b090dafa0a31;hb=d0800f7661f13fabe7bb6f4aa0ea50764f106405;hp=f56c1b2c30c1d8775d69b4c780c9313bd17313f6;hpb=4c1def5fd8e9f483238eb38e221f555e2e6bbf07;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts index f56c1b2c3..6e8e47acb 100644 --- a/server/initializers/migrations/0075-video-resolutions.ts +++ b/server/initializers/migrations/0075-video-resolutions.ts @@ -1,7 +1,7 @@ import * as Sequelize from 'sequelize' import { join } from 'path' import { CONFIG } from '../../initializers/config' -import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' +import { getVideoFileResolution } from '../../helpers/ffprobe-utils' import { readdir, rename } from 'fs-extra' function up (utils: { @@ -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) })