diff options
Diffstat (limited to 'server/initializers/migrations/0065-video-file-size.ts')
-rw-r--r-- | server/initializers/migrations/0065-video-file-size.ts | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/server/initializers/migrations/0065-video-file-size.ts b/server/initializers/migrations/0065-video-file-size.ts index 1aeb27f2d..ac952a98c 100644 --- a/server/initializers/migrations/0065-video-file-size.ts +++ b/server/initializers/migrations/0065-video-file-size.ts | |||
@@ -1,7 +1,4 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { stat } from 'fs-extra' | ||
3 | import { VideoModel } from '../../models/video/video' | ||
4 | import { getVideoFilePath } from '@server/lib/video-paths' | ||
5 | 2 | ||
6 | function up (utils: { | 3 | function up (utils: { |
7 | transaction: Sequelize.Transaction | 4 | transaction: Sequelize.Transaction |
@@ -9,30 +6,7 @@ function up (utils: { | |||
9 | sequelize: Sequelize.Sequelize | 6 | sequelize: Sequelize.Sequelize |
10 | db: any | 7 | db: any |
11 | }): Promise<void> { | 8 | }): Promise<void> { |
12 | return utils.db.Video.listOwnedAndPopulateAuthorAndTags() | 9 | throw new Error('Removed, please upgrade from a previous version first.') |
13 | .then((videos: VideoModel[]) => { | ||
14 | const tasks: Promise<any>[] = [] | ||
15 | |||
16 | videos.forEach(video => { | ||
17 | video.VideoFiles.forEach(videoFile => { | ||
18 | const p = new Promise((res, rej) => { | ||
19 | stat(getVideoFilePath(video, videoFile), (err, stats) => { | ||
20 | if (err) return rej(err) | ||
21 | |||
22 | videoFile.size = stats.size | ||
23 | videoFile.save().then(res).catch(rej) | ||
24 | }) | ||
25 | }) | ||
26 | |||
27 | tasks.push(p) | ||
28 | }) | ||
29 | }) | ||
30 | |||
31 | return tasks | ||
32 | }) | ||
33 | .then((tasks: Promise<any>[]) => { | ||
34 | return Promise.all(tasks) | ||
35 | }) | ||
36 | } | 10 | } |
37 | 11 | ||
38 | function down (options) { | 12 | function down (options) { |