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();
|
||||
|
||||
Reference in New Issue
Block a user