]>
Commit | Line | Data |
---|---|---|
75d612ce | 1 | import { database as db } from '../server/initializers/database' |
571389d4 | 2 | // import { hasFriends } from '../server/lib/friends' |
75d612ce | 3 | |
6fcd19ba C |
4 | db.init(true) |
5 | .then(() => { | |
51548b31 | 6 | // FIXME: check if has following |
571389d4 C |
7 | // return hasFriends() |
8 | return true | |
6fcd19ba C |
9 | }) |
10 | .then(itHasFriends => { | |
75d612ce C |
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.') | |
6fcd19ba C |
17 | return db.Video.list() |
18 | }) | |
19 | .then(videos => { | |
fdbda9e3 C |
20 | const tasks: Promise<any>[] = [] |
21 | ||
93e1258c | 22 | videos.forEach(video => { |
fdbda9e3 C |
23 | console.log('Updating video ' + video.uuid) |
24 | ||
93e1258c | 25 | video.VideoFiles.forEach(file => { |
fdbda9e3 | 26 | tasks.push(video.createTorrentAndSetInfoHash(file)) |
93e1258c | 27 | }) |
75d612ce | 28 | }) |
6fcd19ba | 29 | |
fdbda9e3 C |
30 | return Promise.all(tasks) |
31 | }) | |
32 | .then(() => { | |
6fcd19ba | 33 | process.exit(0) |
75d612ce | 34 | }) |