diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:23:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 16:23:34 +0200 |
commit | 62689b942b71cd1dd0d050c6ed05f884a0b325c2 (patch) | |
tree | c45c35d35d7a3e32621fba06edc63646930c8efd /server/initializers/migrations | |
parent | 84b6dbcc6e8654f39ec798905e1151ba915cd1aa (diff) | |
download | PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.gz PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.tar.zst PeerTube-62689b942b71cd1dd0d050c6ed05f884a0b325c2.zip |
Correctly migrate to fs-extra
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r-- | server/initializers/migrations/0075-video-resolutions.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts index 54ea852b1..26a188e5e 100644 --- a/server/initializers/migrations/0075-video-resolutions.ts +++ b/server/initializers/migrations/0075-video-resolutions.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | |||
4 | import { readdirPromise, renamePromise } from '../../helpers/core-utils' | ||
5 | import { CONFIG } from '../../initializers/constants' | 3 | import { CONFIG } from '../../initializers/constants' |
6 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' | 4 | import { getVideoFileResolution } from '../../helpers/ffmpeg-utils' |
5 | import { readdir, rename } from 'fs-extra' | ||
7 | 6 | ||
8 | function up (utils: { | 7 | function up (utils: { |
9 | transaction: Sequelize.Transaction, | 8 | transaction: Sequelize.Transaction, |
@@ -14,7 +13,7 @@ function up (utils: { | |||
14 | const torrentDir = CONFIG.STORAGE.TORRENTS_DIR | 13 | const torrentDir = CONFIG.STORAGE.TORRENTS_DIR |
15 | const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR | 14 | const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR |
16 | 15 | ||
17 | return readdirPromise(videoFileDir) | 16 | return readdir(videoFileDir) |
18 | .then(videoFiles => { | 17 | .then(videoFiles => { |
19 | const tasks: Promise<any>[] = [] | 18 | const tasks: Promise<any>[] = [] |
20 | for (const videoFile of videoFiles) { | 19 | for (const videoFile of videoFiles) { |
@@ -31,11 +30,11 @@ function up (utils: { | |||
31 | .then(height => { | 30 | .then(height => { |
32 | const oldTorrentName = uuid + '.torrent' | 31 | const oldTorrentName = uuid + '.torrent' |
33 | const newTorrentName = uuid + '-' + height + '.torrent' | 32 | const newTorrentName = uuid + '-' + height + '.torrent' |
34 | return renamePromise(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height) | 33 | return rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => height) |
35 | }) | 34 | }) |
36 | .then(height => { | 35 | .then(height => { |
37 | const newVideoFileName = uuid + '-' + height + '.' + ext | 36 | const newVideoFileName = uuid + '-' + height + '.' + ext |
38 | return renamePromise(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height) | 37 | return rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => height) |
39 | }) | 38 | }) |
40 | .then(height => { | 39 | .then(height => { |
41 | const query = 'UPDATE "VideoFiles" SET "resolution" = ' + height + | 40 | const query = 'UPDATE "VideoFiles" SET "resolution" = ' + height + |