From 91bdf4be63afa2bdfe00e075a589fccbcda009e3 Mon Sep 17 00:00:00 2001 From: Mikael Mello Date: Wed, 17 Oct 2018 09:02:39 -0300 Subject: [PATCH] Make description an optional field for backups Checks whether it has been set and acts accordingly to avoid exceptions Update migration to initialize all existent rows to Description=''. Note that after some research, default values for TEXT columns were not supported by MySQL a few years ago, however Duplicati uses SQLite which seems to fully support this feature. If not, a workaround is to use: ALTER TABLE "Backup" ADD COLUMN "Description" TEXT NULL; UPDATE "Backup" SET "Description"='' WHERE "Description" IS NULL; ALTER TABLE "Backup" ALTER COLUMN "Description" TEXT NOT NULL; --- Duplicati/Server/Database/Connection.cs | 2 +- .../Database schema/6. Add Description to Backup.sql | 2 +- .../ngax/scripts/controllers/EditBackupController.js | 8 +++++++- Duplicati/Server/webroot/ngax/templates/addoredit.html | 2 +- Duplicati/Server/webroot/ngax/templates/home.html | 10 ++++++---- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Duplicati/Server/Database/Connection.cs b/Duplicati/Server/Database/Connection.cs index 320f2f2c0..0b4d140be 100644 --- a/Duplicati/Server/Database/Connection.cs +++ b/Duplicati/Server/Database/Connection.cs @@ -518,7 +518,7 @@ namespace Duplicati.Server.Database return new object[] { n.Name, - n.Description, + n.Description == null ? "" : n.Description, // Description is optional but the column is set to NOT NULL, an additional check is welcome string.Join(",", n.Tags ?? new string[0]), n.TargetURL, update ? (object)item.ID : (object)n.DBPath diff --git a/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql b/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql index 61e5edeb1..1b6ae99eb 100644 --- a/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql +++ b/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql @@ -1 +1 @@ -ALTER TABLE "Backup" ADD COLUMN "Description" TEXT NULL; +ALTER TABLE "Backup" ADD COLUMN "Description" TEXT NOT NULL DEFAULT ''; diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js index 0aa3b2f3b..bc809d2be 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/EditBackupController.js @@ -221,7 +221,6 @@ backupApp.controller('EditBackupController', function ($rootScope, $scope, $rout return; } - if (encryptionEnabled) { if ($scope.PassphraseScore === '') { DialogService.dialog(gettextCatalog.getString('Missing passphrase'), gettextCatalog.getString('You must enter a passphrase or disable encryption')); @@ -487,6 +486,13 @@ backupApp.controller('EditBackupController', function ($rootScope, $scope, $rout var filters = $scope.Backup.Filters; $scope.Backup.Filters = []; + // If Description is anything other than a string, we are either creating a new + // backup or something went wrong when retrieving an existing one + // Either way we should set it to an empty string + if (typeof $scope.Backup.Description !== 'string') { + $scope.Backup.Description = ''; + } + $scope.Backup.Sources = $scope.Backup.Sources || []; for(var ix in filters) diff --git a/Duplicati/Server/webroot/ngax/templates/addoredit.html b/Duplicati/Server/webroot/ngax/templates/addoredit.html index fdde1d45d..2f7f76b5d 100755 --- a/Duplicati/Server/webroot/ngax/templates/addoredit.html +++ b/Duplicati/Server/webroot/ngax/templates/addoredit.html @@ -40,7 +40,7 @@
- +
diff --git a/Duplicati/Server/webroot/ngax/templates/home.html b/Duplicati/Server/webroot/ngax/templates/home.html index 3931ebceb..f9a634629 100644 --- a/Duplicati/Server/webroot/ngax/templates/home.html +++ b/Duplicati/Server/webroot/ngax/templates/home.html @@ -13,10 +13,12 @@
-
Description:
-
- {{item.Backup.Description}} -
+ +
Description:
+
+ {{item.Backup.Description}} +
+
Operations: