mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: restore: fix database name parse
This commit is contained in:
1 parent
006468cd24
commit
32f34ba187
2 files changed
+3
-3
No files matched your search
@@ -72,7 +72,7 @@ require.extensions['.ts'] = require.extensions['.tsx'] = function loader(module,
|
||||
function buildUrl(opts) {
|
||||
let mongourl = `${opts.protocol || 'mongodb'}://`;
|
||||
if (opts.username) mongourl += `${opts.username}:${opts.password}@`;
|
||||
mongourl += `${opts.host}:${opts.port}/${opts.db}`;
|
||||
mongourl += `${opts.host}:${opts.port}/${opts.name}`;
|
||||
if (opts.url) mongourl = opts.url;
|
||||
return mongourl;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ if (argv.args[0] === 'restore') {
|
||||
return;
|
||||
}
|
||||
exec('unzip', [argv.args[1], '-d', dir], { stdio: 'inherit' });
|
||||
exec('mongorestore', [`--uri=${url}`, `--dir=${dir}/dump/${JSON.parse(dbConfig).db}`, '--drop'], { stdio: 'inherit' });
|
||||
exec('mongorestore', [`--uri=${url}`, `--dir=${dir}/dump/${JSON.parse(dbConfig).name}`, '--drop'], { stdio: 'inherit' });
|
||||
if (fs.existsSync(`${dir}/file`)) {
|
||||
exec('rm', ['-rf', '/data/file/*'], { stdio: 'inherit' });
|
||||
exec('mv', [`${dir}/file/*`, '/data/file'], { stdio: 'inherit' });
|
||||
|
||||
Reference in new issue
Block a user