aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-06 13:35:25 +0200
committerChocobozzz <me@florianbigard.com>2021-08-06 14:13:26 +0200
commit679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 (patch)
tree03abf589275db05e5b1fa1c89f57049cd807324a /server/initializers/migrations
parentc826f34a45757b324a20f71665b44ed10e6953b5 (diff)
downloadPeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip
Improve target bitrate calculation
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0075-video-resolutions.ts18
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 })