vjudge: Provider.Langs (#852)

This commit is contained in:
undefined authored and GitHub committed 2024-08-10 23:14:52 +08:00
1 parent a1d392a409
commit 41e3f59579
8 files changed
+109 -101

No files matched your search

+15 -2
View File
@@ -25,6 +25,11 @@ export default class MigrationService extends Service {
this.channels[name] = s;
}
dontWait(func: () => Promise<void | boolean>, name: string) {
(func as any).dontWait = name;
return func;
}
async doUpgrade() {
this.called = true;
for (const channel in this.channels) {
@@ -45,8 +50,16 @@ export default class MigrationService extends Service {
continue;
}
logger.info('Upgrading database [%s]: from %d to %d', channel, dbVer, expected);
const result = await func();
if (!result) break;
if ('dontWait' in func) {
logger.info('[Background Task]');
// For those scripts we don't really care if they fail
func().then(() => {
logger.info('Background Task Completed [%s]: from %d to %d', channel, func.dontWait, expected);
}).catch(logger.error);
} else {
const result = await func();
if (!result) break;
}
dbVer++;
await system.set(name, dbVer);
}