From f4511d0bbb8fb266e2dfeef3050ca4be40d19b77 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Thu, 9 Nov 2017 17:59:36 +0100 Subject: [PATCH] Updated the `affected` command to check if the local database is found, and to return an error if not. Also updated the help text to indicate that a database is required. --- Duplicati/CommandLine/help.txt | 2 +- Duplicati/Library/Main/Operation/ListAffected.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Duplicati/CommandLine/help.txt b/Duplicati/CommandLine/help.txt index cab82daf6..27b2d8395 100644 --- a/Duplicati/CommandLine/help.txt +++ b/Duplicati/CommandLine/help.txt @@ -269,7 +269,7 @@ Usage: test-filters [] Usage: affected [] [] - Returns a report explaining what backup sets and files are affected by a remote file. You can use this option to see what source files are affected if one or more remote files are damaged or deleted. + Returns a report explaining what backup sets and files are affected by a remote file. You can use this option to see what source files are affected if one or more remote files are damaged or deleted. Notes that this command requires a local database to be present, if the database is not found automatically, you can set --dbpath to point to the database to use. # ============================================================================= > duplicati.commandline.exe help vacuum diff --git a/Duplicati/Library/Main/Operation/ListAffected.cs b/Duplicati/Library/Main/Operation/ListAffected.cs index b5a491269..aee7c2bec 100644 --- a/Duplicati/Library/Main/Operation/ListAffected.cs +++ b/Duplicati/Library/Main/Operation/ListAffected.cs @@ -18,7 +18,8 @@ using System; using System.Linq; using System.Collections.Generic; - +using Duplicati.Library.Interface; + namespace Duplicati.Library.Main.Operation { internal class ListAffected @@ -34,6 +35,9 @@ namespace Duplicati.Library.Main.Operation public void Run(List args, Action callback = null) { + if (!System.IO.File.Exists(m_options.Dbpath)) + throw new UserInformationException(string.Format("Database file does not exist: {0}", m_options.Dbpath)); + using(var db = new Database.LocalListAffectedDatabase(m_options.Dbpath)) { m_result.SetDatabase(db);