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