Fix issue deleting app dir during restore

During restore, only the superfluous addons are teardown. Rest of
the addons are kept as-is. This is done to preserve the addon
configuration across restores (thus preserving db passwords).

We then rely on the restoreApp logic to call restore in each addon.
Each restore currently setup, clear and them imports the backup.

With the volume changes, we have moved volume create/delete to the
localstorage addon. Currently, the localstorage addon has no concept of restore
because the backup download extracts it directly into the volume.

Because of the above, during the restore code path, we don't teardown
the localstorage addon and thus files are left behind in appid/data/. This
prevents deleteAppDir() from removing the appid/ directory.

The fix is to add a new 'clear' command to addons. Before restore, we
clear the addons.
This commit is contained in:
Girish Ramakrishnan
2018-09-15 17:05:04 -07:00
parent 46a00c839b
commit 64a7b80395
3 changed files with 174 additions and 60 deletions

View File

@@ -18,7 +18,8 @@ exports = module.exports = {
inspectByName: inspect,
execContainer: execContainer,
createVolume: createVolume,
removeVolume: removeVolume
removeVolume: removeVolume,
clearVolume: clearVolume
};
function connectionInstance() {
@@ -469,6 +470,15 @@ function createVolume(app, name, subdir, callback) {
});
}
function clearVolume(app, name, subdir, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof name, 'string');
assert.strictEqual(typeof subdir, 'string');
assert.strictEqual(typeof callback, 'function');
shell.sudo('removeVolume', [ RMVOLUME_CMD, app.id, subdir ], callback);
}
function removeVolume(app, name, subdir, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof name, 'string');