import: add prefix support

it is incorrect to ignore the prefix. the keys (for s3) and permissions (managed mounts)
might work only inside the prefix.
This commit is contained in:
Girish Ramakrishnan
2024-06-25 13:35:28 +02:00
parent 8f1f3cea18
commit 6f37bde55d
2 changed files with 31 additions and 29 deletions

View File

@@ -1433,7 +1433,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
provider: '',
bucket: '',
prefix: '',
mountPoint: '',
mountPoint: '', // for mountpoint
accessKeyId: '',
secretAccessKey: '',
gcsKey: { keyFileName: '', content: '' },
@@ -1492,7 +1492,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
// only set provider specific fields, this will clear them in the db
if ($scope.s3like(backupConfig.provider)) {
backupConfig.bucket = $scope.importBackup.bucket;
backupConfig.prefix = '';
backupConfig.prefix = $scope.importBackup.prefix;
backupConfig.accessKeyId = $scope.importBackup.accessKeyId;
backupConfig.secretAccessKey = $scope.importBackup.secretAccessKey;
@@ -1539,7 +1539,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
}
} else if (backupConfig.provider === 'gcs') {
backupConfig.bucket = $scope.importBackup.bucket;
backupConfig.prefix = '';
backupConfig.prefix = $scope.importBackup.prefix;
try {
var serviceAccountKey = JSON.parse($scope.importBackup.gcsKey.content);
backupConfig.projectId = serviceAccountKey.project_id;
@@ -1559,9 +1559,9 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
}
} else if (backupConfig.provider === 'sshfs' || backupConfig.provider === 'cifs' || backupConfig.provider === 'nfs' || backupConfig.provider === 'ext4' || backupConfig.provider === 'xfs') {
backupConfig.mountOptions = $scope.importBackup.mountOptions;
backupConfig.prefix = '';
backupConfig.prefix = $scope.importBackup.prefix;
} else if (backupConfig.provider === 'mountpoint') {
backupConfig.prefix = '';
backupConfig.prefix = $scope.importBackup.prefix;
backupConfig.mountPoint = $scope.importBackup.mountPoint;
} else if (backupConfig.provider === 'filesystem') {
var parts = remotePath.split('/');
@@ -2240,13 +2240,9 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
var backupConfig;
try {
backupConfig = JSON.parse(result.target.result);
let prefix = backupConfig.prefix;
backupConfig.prefix = ''; // so it can clear the form as well when we apply keys below
if (backupConfig.provider === 'filesystem') { // patch the remotePath to have the full path
backupConfig.remotePath = (prefix ? prefix + '/' : '') + backupConfig.backupFolder + '/' + backupConfig.remotePath;
if (backupConfig.provider === 'filesystem') { // this allows a user to upload a backup to server and import easily with an absolute path
backupConfig.remotePath = backupConfig.backupFolder + '/' + backupConfig.remotePath;
delete backupConfig.backupFolder;
} else {
backupConfig.remotePath = (prefix ? prefix + '/' : '') + backupConfig.remotePath;
}
} catch (e) {
console.error('Unable to parse backup config');