-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetchMatchlog.js
More file actions
47 lines (34 loc) · 1.25 KB
/
fetchMatchlog.js
File metadata and controls
47 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const Fetch = require("./src/server/services/Fetch");
const ReplayManager = require("./src/server/services/ReplayManager");
const FtpUtil = require("./src/utils/FtpUtil");
const ftpConfig = require("./config/ftpConfig");
const fetch = new Fetch();
let ftp;
async function start() {
ftp = await FtpUtil.connect(ftpConfig.nc1);
const matchlogs = await fetch.fetchMatchlog(ftp);
await ftp.end();
for (let matchlogEntry of matchlogs) {
try {
ftp = await FtpUtil.connect(ftpConfig.nc1);
const result = await ReplayManager.fetchReplays(ftp, matchlogEntry.replaysRemotePath);
if (result) {
await ReplayManager.removeRemoteReplays(ftp, matchlogEntry.replaysRemotePath);
}
await ftp.end();
// TODO: Only remove local replays if we are sure that upload was successful.
ftp = await FtpUtil.connect(ftpConfig.replayStorage);
await ReplayManager.saveReplays(matchlogEntry.db, ftp);
await ftp.end();
ReplayManager.removeLocalReplays();
}
catch(e) {
console.log(e);
}
}
console.log("All tasks completed.")
}
start();
setInterval(async () => {
await start();
}, 180 * 1000);