If app.dataDir is set, first unmount from sftp before deleting on uninstall
This commit is contained in:
@@ -743,7 +743,7 @@ function migrateDataDir(app, args, progressCallback, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We do this after the app has the new data commited to the database
|
// We do this after the app has the new data commited to the database
|
||||||
sftp.rebuild(function (error) {
|
sftp.rebuild({}, function (error) {
|
||||||
if (error) console.error('Failed to rebuild sftp addon:', error);
|
if (error) console.error('Failed to rebuild sftp addon:', error);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
@@ -984,16 +984,22 @@ function uninstall(app, args, progressCallback, callback) {
|
|||||||
progressCallback.bind(null, { percent: 30, message: 'Teardown addons' }),
|
progressCallback.bind(null, { percent: 30, message: 'Teardown addons' }),
|
||||||
addons.teardownAddons.bind(null, app, app.manifest.addons),
|
addons.teardownAddons.bind(null, app, app.manifest.addons),
|
||||||
|
|
||||||
progressCallback.bind(null, { percent: 40, message: 'Deleting app data directory' }),
|
progressCallback.bind(null, { percent: 40, message: 'Remove sftp addon binding' }),
|
||||||
|
function (callback) {
|
||||||
|
if (!app.dataDir) return callback();
|
||||||
|
sftp.rebuild({ ignoredDataDirs: [ app.dataDir ] }, callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
progressCallback.bind(null, { percent: 50, message: 'Deleting app data directory' }),
|
||||||
deleteAppDir.bind(null, app, { removeDirectory: true }),
|
deleteAppDir.bind(null, app, { removeDirectory: true }),
|
||||||
|
|
||||||
progressCallback.bind(null, { percent: 50, message: 'Deleting image' }),
|
progressCallback.bind(null, { percent: 60, message: 'Deleting image' }),
|
||||||
docker.deleteImage.bind(null, app.manifest),
|
docker.deleteImage.bind(null, app.manifest),
|
||||||
|
|
||||||
progressCallback.bind(null, { percent: 60, message: 'Unregistering domains' }),
|
progressCallback.bind(null, { percent: 70, message: 'Unregistering domains' }),
|
||||||
unregisterSubdomains.bind(null, app, [ { subdomain: app.location, domain: app.domain } ].concat(app.alternateDomains)),
|
unregisterSubdomains.bind(null, app, [ { subdomain: app.location, domain: app.domain } ].concat(app.alternateDomains)),
|
||||||
|
|
||||||
progressCallback.bind(null, { percent: 70, message: 'Cleanup icon' }),
|
progressCallback.bind(null, { percent: 80, message: 'Cleanup icon' }),
|
||||||
removeIcon.bind(null, app),
|
removeIcon.bind(null, app),
|
||||||
|
|
||||||
progressCallback.bind(null, { percent: 90, message: 'Cleanup logs' }),
|
progressCallback.bind(null, { percent: 90, message: 'Cleanup logs' }),
|
||||||
|
|||||||
13
src/sftp.js
13
src/sftp.js
@@ -19,12 +19,16 @@ function startSftp(existingInfra, callback) {
|
|||||||
|
|
||||||
if (existingInfra.version === infra.version && infra.images.sftp.tag === existingInfra.images.sftp.tag) return callback();
|
if (existingInfra.version === infra.version && infra.images.sftp.tag === existingInfra.images.sftp.tag) return callback();
|
||||||
|
|
||||||
rebuild(callback);
|
rebuild({}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rebuild(callback) {
|
// options only supports ignoredDataDirs = [ pathString ]
|
||||||
|
function rebuild(options, callback) {
|
||||||
|
assert.strictEqual(typeof options, 'object');
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
|
if (options.ignoredDataDirs) assert(Array.isArray(options.ignoredDataDirs), 'Expecting ignoredDataDirs to be an array');
|
||||||
|
|
||||||
debug('rebuilding container');
|
debug('rebuilding container');
|
||||||
|
|
||||||
const tag = infra.images.sftp.tag;
|
const tag = infra.images.sftp.tag;
|
||||||
@@ -37,6 +41,11 @@ function rebuild(callback) {
|
|||||||
result.forEach(function (app) {
|
result.forEach(function (app) {
|
||||||
if (!app.dataDir) return;
|
if (!app.dataDir) return;
|
||||||
|
|
||||||
|
if (options.ignoredDataDirs && options.ignoredDataDirs.indexOf(app.dataDir) !== -1) {
|
||||||
|
debug(`Ignoring dataDir ${app.dataDir}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dataDirs.push({
|
dataDirs.push({
|
||||||
hostDir: app.dataDir,
|
hostDir: app.dataDir,
|
||||||
// /data is required since this is where the localstorage data would be in APPS_DATA_DIR
|
// /data is required since this is where the localstorage data would be in APPS_DATA_DIR
|
||||||
|
|||||||
Reference in New Issue
Block a user