diff options
author | Kenneth Hsu <kennethhsu@gmail.com> | 2021-05-19 07:28:23 +0300 |
---|---|---|
committer | Kenneth Hsu <kennethhsu@gmail.com> | 2021-05-20 23:42:41 +0300 |
commit | e90eb3b2a3ea0b76a157868870b4fb8a004a34c3 (patch) | |
tree | 48042700557e055b2ebd0f0893ba3b2c61d78da8 /Duplicati | |
parent | 0a43410535d89e3e8ca93e78f799b9cec8812310 (diff) |
Create custom Exception for remote list verification failures.
Previously, we would catch any Exception thrown by VerifyRemoteList and
perform an auto-cleanup (if specified in the options). However, we
should only perform the auto-cleanup if VerifyRemoteList detected an
issue with the uploaded files. Otherwise, an unrelated exception can
cause the database repair to be performed unnecessarily. In the case of
a connection issue, this can leave the database in a corrupted state.
This fixes #4516.
Diffstat (limited to 'Duplicati')
-rw-r--r-- | Duplicati/Library/Interface/CustomExceptions.cs | 16 | ||||
-rw-r--r-- | Duplicati/Library/Main/Operation/BackupHandler.cs | 2 | ||||
-rw-r--r-- | Duplicati/Library/Main/Operation/FilelistProcessor.cs | 8 |
3 files changed, 21 insertions, 5 deletions
diff --git a/Duplicati/Library/Interface/CustomExceptions.cs b/Duplicati/Library/Interface/CustomExceptions.cs index 2e0c90262..1dbc0ff63 100644 --- a/Duplicati/Library/Interface/CustomExceptions.cs +++ b/Duplicati/Library/Interface/CustomExceptions.cs @@ -183,4 +183,20 @@ namespace Duplicati.Library.Interface AbortReason = reason;
}
}
+
+ /// <summary>
+ /// An exception indicating that verification of uploaded volumes has failed
+ /// due to extra, missing, or duplicate files.
+ /// </summary>
+ [Serializable]
+ public class RemoteListVerificationException : UserInformationException
+ {
+ public RemoteListVerificationException(string message, string helpId)
+ : base(message, helpId)
+ {}
+
+ public RemoteListVerificationException(string message, string helpId, Exception innerException)
+ : base(message, helpId, innerException)
+ {}
+ }
}
diff --git a/Duplicati/Library/Main/Operation/BackupHandler.cs b/Duplicati/Library/Main/Operation/BackupHandler.cs index f78246cdd..ef12b94e8 100644 --- a/Duplicati/Library/Main/Operation/BackupHandler.cs +++ b/Duplicati/Library/Main/Operation/BackupHandler.cs @@ -156,7 +156,7 @@ namespace Duplicati.Library.Main.Operation else
FilelistProcessor.VerifyRemoteList(backend, m_options, m_database, m_result.BackendWriter, new string[] { protectedfile });
}
- catch (Exception ex)
+ catch (RemoteListVerificationException ex)
{
if (m_options.AutoCleanup)
{
diff --git a/Duplicati/Library/Main/Operation/FilelistProcessor.cs b/Duplicati/Library/Main/Operation/FilelistProcessor.cs index 643c0110f..0652020d8 100644 --- a/Duplicati/Library/Main/Operation/FilelistProcessor.cs +++ b/Duplicati/Library/Main/Operation/FilelistProcessor.cs @@ -113,7 +113,7 @@ namespace Duplicati.Library.Main.Operation {
var s = string.Format("Found {0} remote files that are not recorded in local storage, please run repair", extraCount);
Logging.Log.WriteErrorMessage(LOGTAG, "ExtraRemoteFiles", null, s);
- throw new Duplicati.Library.Interface.UserInformationException(s, "ExtraRemoteFiles");
+ throw new RemoteListVerificationException(s, "ExtraRemoteFiles");
}
ISet<string> doubles;
@@ -123,7 +123,7 @@ namespace Duplicati.Library.Main.Operation {
var s = string.Format("Found remote files reported as duplicates, either the backend module is broken or you need to manually remove the extra copies.\nThe following files were found multiple times: {0}", string.Join(", ", doubles));
Logging.Log.WriteErrorMessage(LOGTAG, "DuplicateRemoteFiles", null, s);
- throw new Duplicati.Library.Interface.UserInformationException(s, "DuplicateRemoteFiles");
+ throw new RemoteListVerificationException(s, "DuplicateRemoteFiles");
}
if (missingCount > 0)
@@ -135,7 +135,7 @@ namespace Duplicati.Library.Main.Operation s = string.Format("Found {0} files that are missing from the remote storage, please run repair", missingCount);
Logging.Log.WriteErrorMessage(LOGTAG, "MissingRemoteFiles", null, s);
- throw new Duplicati.Library.Interface.UserInformationException(s, "MissingRemoteFiles");
+ throw new RemoteListVerificationException(s, "MissingRemoteFiles");
}
}
@@ -279,7 +279,7 @@ namespace Duplicati.Library.Main.Operation if (e.Value == RemoteVolumeState.Uploading || e.Value == RemoteVolumeState.Temporary)
database.UnlinkRemoteVolume(e.Key, e.Value);
else
- throw new Exception(string.Format("The remote volume {0} appears in the database with state {1} and a deleted state, cannot continue", e.Key, e.Value.ToString()));
+ throw new RemoteListVerificationException(string.Format("The remote volume {0} appears in the database with state {1} and a deleted state, cannot continue", e.Key, e.Value.ToString()), "AmbiguousStateRemoteFiles");
}
var locallist = database.GetRemoteVolumes();
|