- return utils.db.Video.listOwnedAndPopulateAuthorAndTags()
- .then((videos: VideoInstance[]) => {
- const tasks: Promise<any>[] = []
-
- videos.forEach(video => {
- video.VideoFiles.forEach(videoFile => {
- const p = new Promise((res, rej) => {
- stat(video.getVideoFilePath(videoFile), (err, stats) => {
- if (err) return rej(err)
-
- videoFile.size = stats.size
- videoFile.save().then(res).catch(rej)
- })
- })
-
- tasks.push(p)
- })
- })
-
- return tasks
- })
- .then((tasks: Promise<any>[]) => {
- return Promise.all(tasks)
- })