sftp: only mount data dirs that exist

when restoring, the platform starts first and the sftp container
goes and creates app data dirs with root permission. this prevents
the app restore logic from downloading the backup since it expects
yellowtent perm
This commit is contained in:
Girish Ramakrishnan
2020-08-09 12:10:20 -07:00
parent aeee8afc02
commit 2f9fe30c9d
+9 -4
View File
@@ -10,6 +10,7 @@ var apps = require('./apps.js'),
async = require('async'),
debug = require('debug')('box:sftp'),
infra = require('./infra_version.js'),
safe = require('safetydance'),
shell = require('./shell.js');
function startSftp(existingInfra, callback) {
@@ -45,10 +46,14 @@ function rebuild(options, callback) {
return;
}
dataDirs.push({
hostDir: apps.getDataDir(app, app.dataDir),
mountDir: `/app/data/${app.id}`
});
const hostDir = apps.getDataDir(app, app.dataDir), mountDir = `/app/data/${app.id}`;
if (!safe.fs.existsSync(hostDir)) {
// do not create host path when cloudron is restoring. this will then create dir with root perms making restore logic fail
debug(`Ignoring volume for ${app.id} since it does not exist`);
return;
}
dataDirs.push({ hostDir, mountDir });
});
debug('app volume mounts', dataDirs);