mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: restore: ignore old env
This commit is contained in:
1 parent
53ea4e758a
commit
a8111c2ecc
2 files changed
+9
-13
No files matched your search
@@ -46,13 +46,14 @@ function judgeSubtask(subtask: NormalizedSubtask, sid: string, judgeCase: Task['
|
||||
memory: 0,
|
||||
message: '',
|
||||
} : await runner(ctx, ctxSubtask, runner);
|
||||
if (!res) return;
|
||||
ctxSubtask.score = Score[ctxSubtask.subtask.type](ctxSubtask.score, res.score);
|
||||
ctxSubtask.status = Math.max(ctxSubtask.status, res.status);
|
||||
if (ctxSubtask.status > STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
|
||||
ctx.total_time += res.time;
|
||||
ctx.total_memory = Math.max(ctx.total_memory, res.memory);
|
||||
ctx.next({ case: res, addProgress: 100 / ctx.config.count });
|
||||
if (res?.status !== STATUS.STATUS_CANCELED) {
|
||||
ctxSubtask.score = Score[ctxSubtask.subtask.type](ctxSubtask.score, res.score);
|
||||
ctxSubtask.status = Math.max(ctxSubtask.status, res.status);
|
||||
if (ctxSubtask.status > STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
|
||||
ctx.total_time += res.time;
|
||||
ctx.total_memory = Math.max(ctx.total_memory, res.memory);
|
||||
}
|
||||
ctx.next({ ...res ? { case: res } : {}, addProgress: 100 / ctx.config.count });
|
||||
}));
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -63,8 +63,6 @@ if (!argv.args[0] || argv.args[0] === 'cli') {
|
||||
const url = buildUrl(JSON.parse(dbConfig));
|
||||
const dir = `${os.tmpdir()}/${Math.random().toString(36).substring(2)}`;
|
||||
exec('mongodump', [url, `--out=${dir}/dump`], { stdio: 'inherit' });
|
||||
const env = `${os.homedir()}/.hydro/env`;
|
||||
if (fs.existsSync(env)) fs.copySync(env, `${dir}/env`);
|
||||
const target = `${process.cwd()}/backup-${new Date().toISOString().replace(':', '-').split(':')[0]}.zip`;
|
||||
exec('zip', ['-r', target, 'dump'], { cwd: dir, stdio: 'inherit' });
|
||||
if (!argv.options.dbOnly) {
|
||||
@@ -84,12 +82,9 @@ if (!argv.args[0] || argv.args[0] === 'cli') {
|
||||
exec('unzip', [filename, '-d', dir], { stdio: 'inherit' });
|
||||
exec('mongorestore', [`--uri=${url}`, `--dir=${dir}/dump/hydro`, '--drop'], { stdio: 'inherit' });
|
||||
if (fs.existsSync(`${dir}/file`)) {
|
||||
exec('rm', ['-rf', '/data/file/*'], { stdio: 'inherit' });
|
||||
exec('rm', ['-rf', '/data/file/hydro'], { stdio: 'inherit' });
|
||||
exec('bash', ['-c', `mv ${dir}/file/* /data/file`], { stdio: 'inherit' });
|
||||
}
|
||||
if (fs.existsSync(`${dir}/env`)) {
|
||||
fs.copySync(`${dir}/env`, `${os.homedir()}/.hydro/env`, { overwrite: true });
|
||||
}
|
||||
fs.removeSync(dir);
|
||||
console.log('Successfully restored.');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user