1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
3 import { stat } from 'fs-extra'
4 import { VideoModel } from '../../models/video/video'
7 transaction: Sequelize.Transaction,
8 queryInterface: Sequelize.QueryInterface,
9 sequelize: Sequelize.Sequelize,
12 return utils.db.Video.listOwnedAndPopulateAuthorAndTags()
13 .then((videos: VideoModel[]) => {
14 const tasks: Promise<any>[] = []
16 videos.forEach(video => {
17 video.VideoFiles.forEach(videoFile => {
18 const p = new Promise((res, rej) => {
19 stat(video.getVideoFilePath(videoFile), (err, stats) => {
20 if (err) return rej(err)
22 videoFile.size = stats.size
23 videoFile.save().then(res).catch(rej)
33 .then((tasks: Promise<any>[]) => {
34 return Promise.all(tasks)
38 function down (options) {
39 throw new Error('Not implemented.')