core: check isFunction for script

This commit is contained in:
undefined committed 2021-04-07 16:10:12 +08:00
1 parent 0d86bd9ddc
commit 30f82ae82b
2 files changed
+7 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.21.15", "version": "2.21.16",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
+6 -2
View File
@@ -75,8 +75,12 @@ export async function load(call: Entry) {
while (dbVer < expected) { while (dbVer < expected) {
logger.info('Upgrading database: from %d to %d', dbVer, expected); logger.info('Upgrading database: from %d to %d', dbVer, expected);
const func = scripts[dbVer]; const func = scripts[dbVer];
if (typeof func !== 'function') {
dbVer++;
continue;
}
if (isFresh) { if (isFresh) {
if (typeof func !== 'function' || func.toString().includes('_FRESH_INSTALL_IGNORE')) { if (func.toString().includes('_FRESH_INSTALL_IGNORE')) {
dbVer++; dbVer++;
continue; continue;
} }
@@ -86,6 +90,6 @@ export async function load(call: Entry) {
dbVer++; dbVer++;
await modelSystem.set('db.ver', dbVer); await modelSystem.set('db.ver', dbVer);
} }
bus.serial('app/started'); await bus.serial('app/started');
return await modelSystem.get('server.worker'); return await modelSystem.get('server.worker');
} }