From dfdb49ec274d99fb67f4d41306016da62e06e77e Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 8 Dec 2015 20:39:47 +0100 Subject: [PATCH] Added check for existing database with ngax --- .../controllers/EditBackupController.js | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js index 538a5c312..721549888 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js @@ -202,9 +202,30 @@ backupApp.controller('EditBackupController', function ($scope, $routeParams, $lo }); if ($routeParams.backupid == null) { - AppService.post('/backups', result, {'headers': {'Content-Type': 'application/json'}}).then(function() { - $location.path('/'); - }, AppUtils.connectionError); + + function postDb() { + AppService.post('/backups', result, {'headers': {'Content-Type': 'application/json'}}).then(function() { + $location.path('/'); + }, AppUtils.connectionError); + }; + + AppService.post('/remoteoperation/dbpath', result.Backup.DBPath).then( + function(resp) { + if (resp.data.Exists) { + DialogService.dialog('Use existing database?', 'An existing local database for the storage has been found.\nRe-using the database will allow the command-line and server instances to work on the same remote storage.\n\n Do you wish to use the existing database?', ['Cancel', 'Yes', 'No'], function(ix) { + if (ix == 2) + result.Backup.DBPath = resp.data.Path; + + if (ix == 1 || ix == 2) + postDb(); + }); + } + else + postDb(); + + }, AppUtils.connectionError + ); + } else { AppService.put('/backup/' + $routeParams.backupid, result, {'headers': {'Content-Type': 'application/json'}}).then(function() { $location.path('/');