diff options
Diffstat (limited to 'server/initializers/migrations/0075-video-resolutions.ts')
-rw-r--r-- | server/initializers/migrations/0075-video-resolutions.ts | 18 |
1 files changed, 8 insertions, 10 deletions
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: { | |||
27 | const ext = matches[2] | 27 | const ext = matches[2] |
28 | 28 | ||
29 | const p = getVideoFileResolution(join(videoFileDir, videoFile)) | 29 | const p = getVideoFileResolution(join(videoFileDir, videoFile)) |
30 | .then(height => { | 30 | .then(async ({ resolution }) => { |
31 | const oldTorrentName = uuid + '.torrent' | 31 | const oldTorrentName = uuid + '.torrent' |
32 | const newTorrentName = uuid + '-' + height + '.torrent' | 32 | const newTorrentName = uuid + '-' + resolution + '.torrent' |
33 | return rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height) | 33 | await rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => resolution) |
34 | }) | 34 | |
35 | .then(height => { | 35 | const newVideoFileName = uuid + '-' + resolution + '.' + ext |
36 | const newVideoFileName = uuid + '-' + height + '.' + ext | 36 | await rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => resolution) |
37 | return rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height) | 37 | |
38 | }) | 38 | const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution + |
39 | .then(height => { | ||
40 | const query = 'UPDATE "VideoFiles" SET "resolution" = ' + height + | ||
41 | ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')' | 39 | ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')' |
42 | return utils.sequelize.query(query) | 40 | return utils.sequelize.query(query) |
43 | }) | 41 | }) |