mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fix problems found by deepscan.io
This commit is contained in:
1 parent
e8dcd97561
commit
dd4ecdb029
13 files changed
+33
-29
No files matched your search
@@ -4,6 +4,7 @@ import axios from 'axios';
|
||||
import AdmZip from 'adm-zip';
|
||||
import fs from 'fs-extra';
|
||||
import WebSocket from 'ws';
|
||||
import { noop } from 'lodash';
|
||||
import * as tmpfs from '../tmpfs';
|
||||
import log from '../log';
|
||||
import { compilerText, Queue } from '../utils';
|
||||
@@ -99,7 +100,7 @@ class JudgeTask {
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const clean of this.clean) await clean().catch();
|
||||
for (const clean of this.clean) await clean().catch(noop);
|
||||
tmpfs.umount(this.tmpdir);
|
||||
fs.removeSync(this.tmpdir);
|
||||
}
|
||||
@@ -257,7 +258,7 @@ export default class VJ4 {
|
||||
});
|
||||
});
|
||||
await fs.unlink(tmpFilePath);
|
||||
await this.processData(savePath).catch();
|
||||
await this.processData(savePath).catch(noop);
|
||||
} catch (e) {
|
||||
if (retry) await this.problemData(domainId, pid, savePath, retry - 1);
|
||||
else throw e;
|
||||
|
||||
@@ -63,7 +63,6 @@ function judgeCase(c) {
|
||||
});
|
||||
}
|
||||
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
|
||||
status = STATUS.STATUS_RUNTIME_ERROR;
|
||||
if (code < 32) message = signals[code];
|
||||
else message = `您的程序返回了 ${code}.`;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const statusMap = {
|
||||
};
|
||||
|
||||
function proc({
|
||||
execute = null,
|
||||
execute = '',
|
||||
time_limit_ms = 16000,
|
||||
memory_limit_mb = 1024,
|
||||
process_limit = 32,
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ObjectID } from 'bson';
|
||||
import fs from 'fs-extra';
|
||||
import { homedir, tmpdir } from 'os';
|
||||
import AdmZip from 'adm-zip';
|
||||
import { noop } from 'lodash';
|
||||
|
||||
declare module 'hydrooj/dist/interface' {
|
||||
interface SystemKeys {
|
||||
@@ -83,7 +84,7 @@ async function postInit() {
|
||||
});
|
||||
});
|
||||
await fs.unlink(tmpFilePath);
|
||||
await processData(savePath).catch();
|
||||
await processData(savePath).catch(noop);
|
||||
return savePath;
|
||||
}
|
||||
|
||||
@@ -239,7 +240,7 @@ async function postInit() {
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
for (const clean of this.clean) await clean().catch();
|
||||
for (const clean of this.clean) await clean().catch(noop);
|
||||
tmpfs.umount(this.tmpdir);
|
||||
fs.removeSync(this.tmpdir);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import systeminformation from 'systeminformation';
|
||||
import { tmpdir } from 'os';
|
||||
import { noop } from 'lodash';
|
||||
import { judge } from './judge/run';
|
||||
import * as tmpfs from './tmpfs';
|
||||
|
||||
@@ -49,7 +50,7 @@ int main(){
|
||||
tmpfs.mount(context.tmpdir, '64m');
|
||||
await judge(context).catch((e) => console.error(e));
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
for (const clean of context.clean) await clean().catch();
|
||||
for (const clean of context.clean) await clean().catch(noop);
|
||||
tmpfs.umount(context.tmpdir);
|
||||
fs.removeSync(context.tmpdir);
|
||||
} catch (e) {
|
||||
|
||||
@@ -13,6 +13,8 @@ const EMPTY_STR = /^[ \r\n\t]*$/i;
|
||||
|
||||
export const cmd = parse;
|
||||
|
||||
export function noop() { }
|
||||
|
||||
export function parseTimeMS(str: string) {
|
||||
const match = TIME_RE.exec(str);
|
||||
if (!match) throw new FormatError(str, ['error parsing time']);
|
||||
|
||||
Reference in new issue
Block a user