From 5bc12e3d46616c2404e06ee8df5da5ed8b00fdc8 Mon Sep 17 00:00:00 2001 From: Carl Johnsen Date: Tue, 10 Dec 2024 06:56:16 +0100 Subject: [PATCH] Changed the reporting of broken local and remote files during restore to only report the first 10 filenames. --- .../Main/Operation/Restore/VolumeDownloader.cs | 7 +++++-- .../Library/Main/Operation/RestoreHandler.cs | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Duplicati/Library/Main/Operation/Restore/VolumeDownloader.cs b/Duplicati/Library/Main/Operation/Restore/VolumeDownloader.cs index 80104aa43..55e1ec746 100644 --- a/Duplicati/Library/Main/Operation/Restore/VolumeDownloader.cs +++ b/Duplicati/Library/Main/Operation/Restore/VolumeDownloader.cs @@ -21,8 +21,10 @@ using System; using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; using CoCoL; +using Duplicati.Library.Main.Database; using Duplicati.Library.Utility; namespace Duplicati.Library.Main.Operation.Restore @@ -43,7 +45,7 @@ namespace Duplicati.Library.Main.Operation.Restore /// /// The restore options. /// The restore results. - public static Task Run(Channels channels, Options options, RestoreResults results) + public static Task Run(Channels channels, LocalRestoreDatabase db, Options options, RestoreResults results) { return AutomationExtensions.RunTask( new @@ -75,9 +77,10 @@ namespace Duplicati.Library.Main.Operation.Restore } catch (Exception) { + var (volume_name, _, _) = db.GetVolumeInfo(volume_id).First(); lock (results) { - results.BrokenRemoteFiles.Add(volume_id); + results.BrokenRemoteFiles.Add(volume_name); } throw; } diff --git a/Duplicati/Library/Main/Operation/RestoreHandler.cs b/Duplicati/Library/Main/Operation/RestoreHandler.cs index efb9fa853..dc6fa5d41 100644 --- a/Duplicati/Library/Main/Operation/RestoreHandler.cs +++ b/Duplicati/Library/Main/Operation/RestoreHandler.cs @@ -344,7 +344,7 @@ namespace Duplicati.Library.Main.Operation var fileprocessors = Enumerable.Range(0, m_options.RestoreFileProcessors).Select(i => Restore.FileProcessor.Run(channels, database, fileprocessor_requests[i], fileprocessor_responses[i], m_options, m_result)).ToArray(); var blockmanager = Restore.BlockManager.Run(channels, database, m_options, fileprocessor_requests, fileprocessor_responses); var volumecache = Restore.VolumeManager.Run(channels, database, backend, m_options, m_result); - var volumedownloaders = Enumerable.Range(0, m_options.RestoreVolumeDownloaders).Select(i => Restore.VolumeDownloader.Run(channels, m_options, m_result)).ToArray(); + var volumedownloaders = Enumerable.Range(0, m_options.RestoreVolumeDownloaders).Select(i => Restore.VolumeDownloader.Run(channels, database, m_options, m_result)).ToArray(); var volumedecryptors = Enumerable.Range(0, m_options.RestoreVolumeDecryptors).Select(i => Restore.VolumeDecryptor.Run(channels, m_options)).ToArray(); var volumedecompressors = Enumerable.Range(0, m_options.RestoreVolumeDecompressors).Select(i => Restore.VolumeDecompressor.Run(channels, m_options)).ToArray(); @@ -383,12 +383,18 @@ namespace Duplicati.Library.Main.Operation if (m_result.BrokenRemoteFiles.Count > 0 || m_result.BrokenLocalFiles.Count > 0) { var nl = Environment.NewLine; - string remoteMessage = m_result.BrokenRemoteFiles.Count > 0 ? $"Failed to download {m_result.BrokenRemoteFiles.Count} remote files." : string.Empty; - string remoteList = m_result.BrokenRemoteFiles.Count > 0 ? $"The following remote files failed to download, which may be the cause:{nl}{string.Join(nl, m_result.BrokenRemoteFiles)}{nl}" : string.Empty; - string localMessage = m_result.BrokenLocalFiles.Count > 0 ? $"Failed to restore {m_result.BrokenLocalFiles.Count} local files." : string.Empty; - string localList = m_result.BrokenLocalFiles.Count > 0 ? $"The following local files failed to restore:{nl}{string.Join(nl, m_result.BrokenLocalFiles)}{nl}" : string.Empty; + int maxN = 10; + long remoteFirstN = Math.Min(maxN, m_result.BrokenRemoteFiles.Count); + string remoteFirst = remoteFirstN < m_result.BrokenRemoteFiles.Count ? $"first {maxN} " : string.Empty; + long localFirstN = Math.Min(maxN, m_result.BrokenLocalFiles.Count); + string localFirst = localFirstN < m_result.BrokenLocalFiles.Count ? $"first {maxN} " : string.Empty; - Logging.Log.WriteInformationMessage(LOGTAG, "RestoreFailures", $"{remoteMessage}{nl}{localMessage}{nl}{remoteList}{nl}{localList}"); + string remoteMessage = m_result.BrokenRemoteFiles.Count > 0 ? $"Failed to download {m_result.BrokenRemoteFiles.Count} remote files." : string.Empty; + string remoteList = m_result.BrokenRemoteFiles.Count > 0 ? $"The following {remoteFirst}remote files failed to download, which may be the cause:{nl}{string.Join(nl, m_result.BrokenRemoteFiles.Take(maxN))}{nl}" : string.Empty; + string localMessage = m_result.BrokenLocalFiles.Count > 0 ? $"Failed to restore {m_result.BrokenLocalFiles.Count} local files." : string.Empty; + string localList = m_result.BrokenLocalFiles.Count > 0 ? $"The following {localFirst}local files failed to restore:{nl}{string.Join(nl, m_result.BrokenLocalFiles.Take(maxN))}{nl}" : string.Empty; + + Logging.Log.WriteErrorMessage(LOGTAG, "RestoreFailures", null, $"{remoteMessage}{nl}{localMessage}{nl}{remoteList}{nl}{localList}"); } else if (m_result.RestoredFiles == 0) Logging.Log.WriteWarningMessage(LOGTAG, "NoFilesRestored", null, "Restore completed without errors but no files were restored");