core: logger upd

This commit is contained in:
undefined committed 2020-12-21 03:06:41 +08:00
1 parent d4088f429a
commit 4d031eb9ab
9 files changed
+141 -131

No files matched your search

+1 -1
View File
@@ -66,7 +66,7 @@ async function postInit() {
const filePath = path.join(homedir(), '.cache', 'hydro', 'judge', domainId, pid);
await fs.ensureDir(filePath);
if (!files.length) throw new SystemError('Problem data not found.');
let etags: Record<string, string>;
let etags: Record<string, string> = {};
try {
etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString());
} catch (e) { /* ignore */ }
+8
View File
@@ -109,6 +109,14 @@ export function restrictFile(p: string) {
export function ensureFile(folder: string) {
return (file: string, message: string) => {
// Historical issue
if (file.includes('/')) {
const f = path.join(folder, restrictFile(file.split('/')[1]));
if (fs.existsSync(f)) {
const stat = fs.statSync(f);
if (stat.isFile()) return f;
}
}
const f = path.join(folder, restrictFile(file));
if (!fs.existsSync(f)) throw new FormatError(message, [file]);
const stat = fs.statSync(f);