]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/migrations/0075-video-resolutions.ts
Merge branch 'release/2.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0075-video-resolutions.ts
index e7d8a287609dc8e8ebf893d13c872652d5439c95..f56c1b2c30c1d8775d69b4c780c9313bd17313f6 100644 (file)
@@ -1,20 +1,19 @@
 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 { CONFIG } from '../../initializers/config'
+import { getVideoFileResolution } from '../../helpers/ffmpeg-utils'
+import { readdir, rename } from 'fs-extra'
 
 function up (utils: {
-  transaction: Sequelize.Transaction,
-  queryInterface: Sequelize.QueryInterface,
-  sequelize: Sequelize.Sequelize,
+  transaction: Sequelize.Transaction
+  queryInterface: Sequelize.QueryInterface
+  sequelize: Sequelize.Sequelize
   db: any
 }): Promise<void> {
   const torrentDir = CONFIG.STORAGE.TORRENTS_DIR
   const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR
 
-  return readdirPromise(videoFileDir)
+  return readdir(videoFileDir)
     .then(videoFiles => {
       const tasks: Promise<any>[] = []
       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 +