]>
Commit | Line | Data |
---|---|---|
1 | import * as Promise from 'bluebird' | |
2 | ||
3 | import { database as db } from '../server/initializers/database' | |
4 | import { hasFriends } from '../server/lib/friends' | |
5 | ||
6 | db.init(true) | |
7 | .then(() => { | |
8 | return hasFriends() | |
9 | }) | |
10 | .then(itHasFriends => { | |
11 | if (itHasFriends === true) { | |
12 | console.log('Cannot update host because you have friends!') | |
13 | process.exit(-1) | |
14 | } | |
15 | ||
16 | console.log('Updating torrent files.') | |
17 | return db.Video.list() | |
18 | }) | |
19 | .then(videos => { | |
20 | const tasks: Promise<any>[] = [] | |
21 | ||
22 | videos.forEach(video => { | |
23 | console.log('Updating video ' + video.uuid) | |
24 | ||
25 | video.VideoFiles.forEach(file => { | |
26 | tasks.push(video.createTorrentAndSetInfoHash(file)) | |
27 | }) | |
28 | }) | |
29 | ||
30 | return Promise.all(tasks) | |
31 | }) | |
32 | .then(() => { | |
33 | process.exit(0) | |
34 | }) |