mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: logger upd
This commit is contained in:
1 parent
d4088f429a
commit
4d031eb9ab
9 files changed
+141
-131
No files matched your search
@@ -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 */ }
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user