restore: fix crashes

This commit is contained in:
Girish Ramakrishnan
2024-04-27 12:46:37 +02:00
parent 366f247910
commit e00db115ad

View File

@@ -206,11 +206,12 @@ async function restoreTask(backupConfig, remotePath, ipv4Config, ipv6Config, opt
gStatus.restore.active = false;
}
async function restore(backupConfig, remotePath, version, ipv4Config, options, auditSource) {
async function restore(backupConfig, remotePath, version, ipv4Config, ipv6Config, options, auditSource) {
assert.strictEqual(typeof backupConfig, 'object'); // format, storage, password
assert.strictEqual(typeof remotePath, 'string');
assert.strictEqual(typeof version, 'string');
assert.strictEqual(typeof ipv4Config, 'object');
assert.strictEqual(typeof ipv6Config, 'object');
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof auditSource, 'object');
@@ -236,13 +237,13 @@ async function restore(backupConfig, remotePath, version, ipv4Config, options, a
}
await backups.setupStorage(backupConfig, paths.MANAGED_BACKUP_MOUNT_DIR); // this validates mountOptions
error = await backups.testStorage(Object.assign({ mountPath: paths.MANAGED_BACKUP_MOUNT_DIR }), backupConfig); // this validates provider and it's api options. requires mountPath
error = await backups.testStorage(Object.assign({ mountPath: paths.MANAGED_BACKUP_MOUNT_DIR }, backupConfig)); // this validates provider and it's api options. requires mountPath
if (error) throw error;
error = await network.testIPv4Config(ipv4Config);
if (error) throw error;
safe(restoreTask(backupConfig, remotePath, ipv4Config, options, auditSource), { debug }); // now that args are validated run the task in the background
safe(restoreTask(backupConfig, remotePath, ipv4Config, ipv6Config, options, auditSource), { debug }); // now that args are validated run the task in the background
} catch (error) {
debug('restore: error. %o', error);
gStatus.restore.active = false;