import: validate and create transient mount point

fixes #788
This commit is contained in:
Girish Ramakrishnan
2021-09-29 20:16:06 -07:00
parent 9729d4adb8
commit 653496f96f
2 changed files with 41 additions and 7 deletions

View File

@@ -153,6 +153,7 @@ const appstore = require('./appstore.js'),
fs = require('fs'),
mail = require('./mail.js'),
manifestFormat = require('cloudron-manifestformat'),
mounts = require('./mounts.js'),
once = require('once'),
os = require('os'),
path = require('path'),
@@ -1903,6 +1904,20 @@ async function importApp(app, data, auditSource) {
// TODO: make this smarter to do a read-only test and check if the file exists in the storage backend
if (backupConfig) {
if (mounts.isMountProvider(backupConfig.provider)) {
backupConfig.mountPoint = `/mnt/appimport-${app.id}`;
error = mounts.validateMountOptions(backupConfig.provider, backupConfig.mountOptions);
if (error) throw error;
const mountObject = { // keep this in sync with the import code in apptask
name: `appimport-${app.id}`,
hostPath: backupConfig.mountPoint,
mountType: backupConfig.provider,
mountOptions: backupConfig.mountOptions
};
await mounts.tryAddMount(mountObject, { timeout: 10 });
}
error = await backups.testProviderConfig(backupConfig);
if (error) throw error;
}