mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
codeql: remove some useless check
This commit is contained in:
1 parent
8c6f9a3b71
commit
07d7a38a1b
7 files changed
+18
-23
No files matched your search
@@ -62,20 +62,18 @@ class FpsProblemImportHandler extends Handler {
|
||||
async post({ domainId }) {
|
||||
if (!this.request.files.file) throw new ValidationError('file');
|
||||
const tasks = [];
|
||||
if (this.request.files.file) {
|
||||
try {
|
||||
const content = fs.readFile(this.request.files.file.path).toString();
|
||||
const result = await xml2js.parseStringPromise(content);
|
||||
tasks.push(result);
|
||||
} catch (e) {
|
||||
const zip = new AdmZip(this.request.files.file.path);
|
||||
for (const entry of zip.getEntries()) {
|
||||
try {
|
||||
const content = entry.getData().toString();
|
||||
const result = await xml2js.parseStringPromise(content);
|
||||
tasks.push(result);
|
||||
} catch { } // eslint-disable-line no-empty
|
||||
}
|
||||
try {
|
||||
const content = fs.readFile(this.request.files.file.path).toString();
|
||||
const result = await xml2js.parseStringPromise(content);
|
||||
tasks.push(result);
|
||||
} catch (e) {
|
||||
const zip = new AdmZip(this.request.files.file.path);
|
||||
for (const entry of zip.getEntries()) {
|
||||
try {
|
||||
const content = entry.getData().toString();
|
||||
const result = await xml2js.parseStringPromise(content);
|
||||
tasks.push(result);
|
||||
} catch { } // eslint-disable-line no-empty
|
||||
}
|
||||
}
|
||||
if (!tasks.length) throw new ValidationError('file');
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
const { argv } = require('yargs');
|
||||
|
||||
if (argv._[0] == 'cache') require('../dist/cache')()
|
||||
else if (!argv._) require('../dist/daemon')();
|
||||
if ((argv._ || [])[0] == 'cache') require('../dist/cache')()
|
||||
else require('../dist/daemon')();
|
||||
@@ -106,7 +106,6 @@ export const judge = async (ctx) => {
|
||||
});
|
||||
}
|
||||
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
|
||||
status = STATUS.STATUS_RUNTIME_ERROR;
|
||||
if (code < 32) message = signals[code];
|
||||
else message = `您的程序返回了 ${code}.`;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class ProblemImportSYZOJHandler extends Handler {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await problem.addTestdata(domainId, docId, entry.entryName, entry.getData());
|
||||
}
|
||||
const filename = p.file_io_input_name ? p.file_io_input_name?.split('.')[0] : null;
|
||||
const filename = p.file_io_input_name ? p.file_io_input_name.split('.')[0] : null;
|
||||
const config = {
|
||||
time: `${p.time_limit}ms`,
|
||||
memory: `${p.memory_limit}m`,
|
||||
|
||||
@@ -128,7 +128,6 @@ export class ProblemReceiveHandler extends Handler {
|
||||
pids: filterPid.length ? filterPid.map((i) => (+i ? +i : i)) : data.pids,
|
||||
}).catch(logAndReturn(logger));
|
||||
if (res instanceof Error) throw new RemoteOnlineJudgeError(res.message);
|
||||
const tasks = [];
|
||||
const pids = [];
|
||||
const { pdocs } = res.body;
|
||||
const files = res.body.links;
|
||||
@@ -142,7 +141,7 @@ export class ProblemReceiveHandler extends Handler {
|
||||
}
|
||||
const pid = await problem.add(domainId, pdoc.pid, pdoc.title, pdoc.content, this.user._id, pdoc.tag, pdoc.category);
|
||||
pids.push(pid);
|
||||
tasks.push(this.syncFiles(domainId, baseUrl, pid, files[i]));
|
||||
this.syncFiles(domainId, baseUrl, pid, files[i]).catch(logAndReturn(logger));
|
||||
await problem.edit(domainId, pid, { html: pdoc.html });
|
||||
}
|
||||
this.back();
|
||||
|
||||
@@ -135,12 +135,11 @@ process.on('uncaughtException', logger.error);
|
||||
const publicTemp = path.resolve(os.tmpdir(), 'hydro', 'public');
|
||||
|
||||
export function addon(addonPath: string) {
|
||||
let modulePath = path.resolve(process.cwd(), addonPath);
|
||||
if (!(fs.existsSync(addonPath) && fs.statSync(addonPath).isFile())) {
|
||||
try {
|
||||
// Is a npm package
|
||||
const packagejson = require.resolve(`${addonPath}/package.json`);
|
||||
modulePath = path.dirname(packagejson);
|
||||
const modulePath = path.dirname(packagejson);
|
||||
const publicPath = path.resolve(modulePath, 'public');
|
||||
if (fs.existsSync(publicPath)) fs.copySync(publicPath, publicTemp);
|
||||
global.addons.push(modulePath);
|
||||
|
||||
@@ -325,7 +325,7 @@ const homework: ContestRule = {
|
||||
const colScore = tsddict[pid]?.penaltyScore || '-';
|
||||
const colOriginalScore = tsddict[pid]?.score || '-';
|
||||
const colTime = tsddict[pid]?.time || '-';
|
||||
const colTimeStr = colTime !== '-' ? misc.formatSeconds(colTime || 0) : '-';
|
||||
const colTimeStr = colTime !== '-' ? misc.formatSeconds(colTime) : '-';
|
||||
if (isExport) {
|
||||
row.push(
|
||||
{ type: 'string', value: colScore },
|
||||
|
||||
Reference in new issue
Block a user