Fix Tune validation
This commit is contained in:
parent
89c265e5bb
commit
a1dc71691d
|
@ -319,16 +319,24 @@ const UploadPage = () => {
|
|||
}
|
||||
|
||||
const parsed = tuneParser.parse(await file.arrayBuffer());
|
||||
const { signature } = parsed.getTune().details;
|
||||
|
||||
if (!parsed.isValid()) {
|
||||
return {
|
||||
result: false,
|
||||
message: 'Tune file is not valid or not supported!',
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
await fetchINIFile(parsed.getTune().details.signature);
|
||||
await fetchINIFile(signature);
|
||||
} catch (e) {
|
||||
signatureNotSupportedWarning((e as Error).message);
|
||||
}
|
||||
|
||||
return {
|
||||
result: parsed.isValid(),
|
||||
message: 'Tune file is not valid!',
|
||||
result: true,
|
||||
message: '',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
@ -23,16 +23,16 @@ class TuneParser {
|
|||
const bibliography = xml.getElementsByTagName('bibliography')[0]?.attributes as any;
|
||||
const versionInfo = xml.getElementsByTagName('versionInfo')[0]?.attributes as any;
|
||||
|
||||
if (!xmlPages || !bibliography || !versionInfo) {
|
||||
if (!xmlPages || !versionInfo) {
|
||||
this.isTuneValid = false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this.tune.details = {
|
||||
author: bibliography.author.value,
|
||||
tuneComment: `${bibliography.tuneComment.value}`.trim(),
|
||||
writeDate: bibliography.writeDate.value,
|
||||
author: bibliography ? bibliography.author.value : '',
|
||||
tuneComment: bibliography ? `${bibliography.tuneComment.value}`.trim() : '',
|
||||
writeDate: bibliography ? bibliography.writeDate.value : '',
|
||||
fileFormat: versionInfo.fileFormat.value,
|
||||
firmwareInfo: versionInfo.firmwareInfo.value,
|
||||
nPages: Number.parseInt(versionInfo.nPages.value, 2),
|
||||
|
|
Loading…
Reference in New Issue