fix lookups on replay paths for website (#1281)
This commit is contained in:
@@ -27,7 +27,16 @@ const TSS_BATTLES_DB_PATH = path.join(STORAGE_ROOT, 'tss_battles.db');
|
||||
fs.mkdirSync(REPLAYS_PATH, { recursive: true });
|
||||
|
||||
function replayDataPath(sessionId) {
|
||||
return path.join(REPLAYS_PATH, String(sessionId).toLowerCase(), 'replay_data.json.gz');
|
||||
const sid = String(sessionId).toLowerCase();
|
||||
const candidates = [
|
||||
path.join(REPLAYS_PATH, 'SRE', sid, 'replay_data.json.gz'),
|
||||
path.join(REPLAYS_PATH, 'TSS', sid, 'replay_data.json.gz'),
|
||||
path.join(REPLAYS_PATH, sid, 'replay_data.json.gz'),
|
||||
];
|
||||
for (const p of candidates) {
|
||||
if (fs.existsSync(p)) return p;
|
||||
}
|
||||
return candidates[0];
|
||||
}
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -162,6 +162,8 @@ const RECAP_SCRIPT = path.join(REPO_ROOT, 'BOT', 'render_recap.py');
|
||||
function resolveReplaySessionDir(sessionId) {
|
||||
const sid = String(sessionId).toLowerCase();
|
||||
const candidates = [
|
||||
path.join(REPLAYS_ROOT, 'SRE', sid),
|
||||
path.join(REPLAYS_ROOT, 'TSS', sid),
|
||||
path.join(REPLAYS_ROOT, sid),
|
||||
path.join(REPLAYS_ROOT, `0${sid}`),
|
||||
path.join(LEGACY_REPLAYS_ROOT, sid),
|
||||
|
||||
Reference in New Issue
Block a user