Commit de15fb02 authored by nanahira's avatar nanahira

fixes

parent 028febf3
......@@ -14,6 +14,7 @@ config.user.bak
/windbot
/decks
/decks_save*
/deck_log
/replays
/node_modules
/ssl
......
......@@ -14,6 +14,7 @@ config.user.bak
/windbot
/decks
/decks_save*
/deck_log
/replays
/node_modules
/ssl
......
......@@ -117,7 +117,7 @@ class Replay
@header == null ? false : @header.isTag
@fromFile: (filePath) ->
Replay.fromBuffer fs.readFileSync filePath
Replay.fromBuffer await fs.promises.readFile filePath
@fromBuffer: (buffer) ->
reader = new ReplayReader buffer
......
......@@ -175,8 +175,8 @@
};
}
static fromFile(filePath) {
return Replay.fromBuffer(fs.readFileSync(filePath));
static async fromFile(filePath) {
return Replay.fromBuffer((await fs.promises.readFile(filePath)));
}
static fromBuffer(buffer) {
......
......@@ -232,14 +232,22 @@ class DataManager {
return allDuelLogs.map(duelLog => duelLog.replayFileName);
}
async clearDuelLog() {
const repo = this.db.getRepository(DuelLog_1.DuelLog);
//await this.db.transaction(async (mdb) => {
const runner = this.db.createQueryRunner();
try {
await repo.clear();
await runner.connect();
await runner.startTransaction();
await runner.query("SET FOREIGN_KEY_CHECKS = 0; ");
await runner.clearTable("duel_log_player");
await runner.clearTable("duel_log");
await runner.query("SET FOREIGN_KEY_CHECKS = 1; ");
await runner.commitTransaction();
}
catch (e) {
await runner.rollbackTransaction();
this.log.warn(`Failed to clear duel logs: ${e.toString()}`);
return [];
}
//});
}
async saveDuelLog(name, roomId, cloudReplayId, replayFilename, roomMode, duelCount, playerInfos) {
const duelLog = new DuelLog_1.DuelLog();
......
......@@ -262,13 +262,21 @@ export class DataManager {
return allDuelLogs.map(duelLog => duelLog.replayFileName);
}
async clearDuelLog() {
const repo = this.db.getRepository(DuelLog);
try {
await repo.clear();
} catch (e) {
this.log.warn(`Failed to clear duel logs: ${e.toString()}`);
return [];
}
//await this.db.transaction(async (mdb) => {
const runner = this.db.createQueryRunner();
try {
await runner.connect();
await runner.startTransaction();
await runner.query("SET FOREIGN_KEY_CHECKS = 0; ");
await runner.clearTable("duel_log_player");
await runner.clearTable("duel_log");
await runner.query("SET FOREIGN_KEY_CHECKS = 1; ");
await runner.commitTransaction();
} catch (e) {
await runner.rollbackTransaction();
this.log.warn(`Failed to clear duel logs: ${e.toString()}`);
}
//});
}
async saveDuelLog(name: string, roomId: number, cloudReplayId: number, replayFilename: string, roomMode: number, duelCount: number, playerInfos: DuelLogPlayerInfo[]) {
const duelLog = new DuelLog();
......
......@@ -27,7 +27,7 @@ let DuelLog = class DuelLog {
getViewJSON(tournamentModeSettings) {
const data = {
id: this.id,
time: moment_1.default(this.time).format("YYYY-MM-DD HH-mm-ss"),
time: moment_1.default(this.time).format("YYYY-MM-DD HH:mm:ss"),
name: this.name + (tournamentModeSettings.show_info ? " (Duel:" + this.duelCount + ")" : ""),
roomid: this.roomId,
cloud_replay_id: "R#" + this.cloudReplayId,
......@@ -42,6 +42,7 @@ let DuelLog = class DuelLog {
};
})
};
return data;
}
};
__decorate([
......
......@@ -44,7 +44,7 @@ export class DuelLog {
getViewJSON(tournamentModeSettings: any) {
const data = {
id: this.id,
time: moment(this.time).format("YYYY-MM-DD HH-mm-ss"),
time: moment(this.time).format("YYYY-MM-DD HH:mm:ss"),
name: this.name + (tournamentModeSettings.show_info ? " (Duel:" + this.duelCount + ")" : ""),
roomid: this.roomId,
cloud_replay_id: "R#" + this.cloudReplayId,
......@@ -59,5 +59,6 @@ export class DuelLog {
}
})
}
return data;
}
}
\ No newline at end of file
......@@ -426,6 +426,11 @@
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"coffeescript": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.5.1.tgz",
"integrity": "sha512-J2jRPX0eeFh5VKyVnoLrfVFgLZtnnmp96WQSLAS8OrLm2wtQLcnikYKe1gViJKDH7vucjuhHvBKKBP3rKcD1tQ=="
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
......@@ -1988,6 +1993,11 @@
}
}
},
"typescript": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz",
"integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ=="
},
"ultron": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz",
......
......@@ -18,6 +18,7 @@
"axios": "^0.19.2",
"bunyan": "^1.8.14",
"challonge": "latest",
"coffeescript": "^2.5.1",
"deepmerge": "latest",
"formidable": "latest",
"geoip-country-lite": "latest",
......@@ -32,12 +33,14 @@
"request": "latest",
"sqlite3": "latest",
"typeorm": "^0.2.29",
"typescript": "^4.0.5",
"underscore": "latest",
"underscore.string": "latest",
"ws": "^1.1.1"
},
"license": "AGPL-3.0",
"scripts": {
"build": "coffee -c *.coffee && tsc",
"start": "node ygopro-server.js",
"tournament": "node ygopro-tournament.js",
"pre": "node ygopro-pre.js",
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment