import * as Sequelize from 'sequelize'
-import * as Promise from 'bluebird'
import { join } from 'path'
-
-import { readdirPromise, renamePromise } from '../../helpers/core-utils'
import { CONFIG } from '../../initializers/constants'
-import { getVideoFileHeight } from '../../helpers/ffmpeg-utils'
+import { getVideoFileResolution } from '../../helpers/ffmpeg-utils'
+import { readdir, rename } from 'fs-extra'
function up (utils: {
transaction: Sequelize.Transaction,
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) {
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 +