codeql: remove some useless check

This commit is contained in:
undefined committed 2021-02-28 14:43:53 +08:00
1 parent 8c6f9a3b71
commit 07d7a38a1b
7 files changed
+18 -23

No files matched your search

+12 -14
View File
@@ -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');