]>
Commit | Line | Data |
---|---|---|
1 | import { getServerActor } from '../server/helpers/utils' | |
2 | import { initDatabaseModels } from '../server/initializers' | |
3 | import { ActorFollowModel } from '../server/models/activitypub/actor-follow' | |
4 | import { VideoModel } from '../server/models/video/video' | |
5 | ||
6 | initDatabaseModels(true) | |
7 | .then(() => { | |
8 | return getServerActor() | |
9 | }) | |
10 | .then(serverAccount => { | |
11 | return ActorFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined) | |
12 | }) | |
13 | .then(res => { | |
14 | return res.total > 0 | |
15 | }) | |
16 | .then(hasFollowing => { | |
17 | if (hasFollowing === true) { | |
18 | console.log('Cannot update host because you follow other servers!') | |
19 | process.exit(-1) | |
20 | } | |
21 | ||
22 | console.log('Updating torrent files.') | |
23 | return VideoModel.list() | |
24 | }) | |
25 | .then(videos => { | |
26 | const tasks: Promise<any>[] = [] | |
27 | ||
28 | videos.forEach(video => { | |
29 | console.log('Updating video ' + video.uuid) | |
30 | ||
31 | video.VideoFiles.forEach(file => { | |
32 | tasks.push(video.createTorrentAndSetInfoHash(file)) | |
33 | }) | |
34 | }) | |
35 | ||
36 | return Promise.all(tasks) | |
37 | }) | |
38 | .then(() => { | |
39 | process.exit(0) | |
40 | }) |