core: fix upgrade

pull/81/head
undefined 4 years ago
parent b833efc8c9
commit 1b0bf4c37f

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.20.47",
"version": "2.20.48",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",

@ -236,9 +236,9 @@ const scripts: UpgradeScript[] = [
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllProblem(['data', 'additional_file'], async (pdoc) => {
const $set: any = {};
const td = pdoc.data.filter((f) => f.name);
const td = (pdoc.data || []).filter((f) => !!f.name);
if (JSON.stringify(td) !== JSON.stringify(pdoc.data)) $set.data = td;
const af = pdoc.additional_file.filter((f) => f.name);
const af = (pdoc.additional_file || []).filter((f) => !!f.name);
if (JSON.stringify(af) !== JSON.stringify(pdoc.additional_file)) $set.additional_file = af;
if (Object.keys($set).length) await problem.edit(pdoc.domainId, pdoc.docId, $set);
});

Loading…
Cancel
Save