Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Hsu <kennethhsu@gmail.com>2019-01-20 08:20:03 +0300
committerKenneth Hsu <kennethhsu@gmail.com>2019-01-23 04:37:55 +0300
commitc79fbf5265c1cfbe01bf03b0e546dbbd9a4a5842 (patch)
treef5aed6bf1d369dc13d97bc74031694654ef037ac /Duplicati/Server/WebServer
parent88ee038f949b13a4fc21127d602f75ee2fcbb1a7 (diff)
Dispose of connection after use.
Diffstat (limited to 'Duplicati/Server/WebServer')
-rw-r--r--Duplicati/Server/WebServer/RESTMethods/Backups.cs25
1 files changed, 13 insertions, 12 deletions
diff --git a/Duplicati/Server/WebServer/RESTMethods/Backups.cs b/Duplicati/Server/WebServer/RESTMethods/Backups.cs
index 4f412baaa..91c028013 100644
--- a/Duplicati/Server/WebServer/RESTMethods/Backups.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/Backups.cs
@@ -127,21 +127,22 @@ namespace Duplicati.Server.WebServer.RESTMethods
Serializable.ImportExportStructure importedStructure = Backups.LoadConfiguration(configurationFile, importMetadata, getPassword);
// This will create the Duplicati-server.sqlite database file if it doesn't exist.
- Duplicati.Server.Database.Connection connection = Program.GetDatabaseConnection(advancedOptions);
-
- if (connection.Backups.Any(x => x.Name.Equals(importedStructure.Backup.Name, StringComparison.OrdinalIgnoreCase)))
+ using (Duplicati.Server.Database.Connection connection = Program.GetDatabaseConnection(advancedOptions))
{
- throw new InvalidOperationException($"A backup with the name {importedStructure.Backup.Name} already exists.");
- }
+ if (connection.Backups.Any(x => x.Name.Equals(importedStructure.Backup.Name, StringComparison.OrdinalIgnoreCase)))
+ {
+ throw new InvalidOperationException($"A backup with the name {importedStructure.Backup.Name} already exists.");
+ }
- string error = connection.ValidateBackup(importedStructure.Backup, importedStructure.Schedule);
- if (!string.IsNullOrWhiteSpace(error))
- {
- throw new InvalidOperationException(error);
- }
+ string error = connection.ValidateBackup(importedStructure.Backup, importedStructure.Schedule);
+ if (!string.IsNullOrWhiteSpace(error))
+ {
+ throw new InvalidOperationException(error);
+ }
- // This creates a new ID and DBPath.
- connection.AddOrUpdateBackupAndSchedule(importedStructure.Backup, importedStructure.Schedule);
+ // This creates a new ID and DBPath.
+ connection.AddOrUpdateBackupAndSchedule(importedStructure.Backup, importedStructure.Schedule);
+ }
return importedStructure;
}