mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
setting: retry write on duplicate_key_error
This commit is contained in:
1 parent
ea38940aee
commit
b4ac4da1fd
2 files changed
+24
-2
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import moment from 'moment-timezone';
|
||||
import { Dictionary } from 'lodash';
|
||||
import yaml from 'js-yaml';
|
||||
import { retry } from '@hydrooj/utils/lib/utils';
|
||||
import * as builtin from './builtin';
|
||||
import { Setting as _Setting } from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
@@ -193,8 +194,7 @@ bus.once('app/started', async () => {
|
||||
if (setting.value) {
|
||||
const current = await global.Hydro.service.db.collection('system').findOne({ _id: setting.key });
|
||||
if (!current || current.value == null || current.value === '') {
|
||||
// @ts-ignore
|
||||
await system.set(setting.key, setting.value);
|
||||
await retry(system.set, setting.key, setting.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user