From 825623be554dc76cdf40562e0e22babeacee58d3 Mon Sep 17 00:00:00 2001 From: Carl Johnsen Date: Mon, 13 Apr 2026 15:07:19 +0200 Subject: [PATCH] Moved adding element to volume cache into its own method to ensure all steps has been taken. --- .../Main/Operation/Restore/VolumeManager.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Duplicati/Library/Main/Operation/Restore/VolumeManager.cs b/Duplicati/Library/Main/Operation/Restore/VolumeManager.cs index 49d2d6b8f..6dcaac7ca 100644 --- a/Duplicati/Library/Main/Operation/Restore/VolumeManager.cs +++ b/Duplicati/Library/Main/Operation/Restore/VolumeManager.cs @@ -146,6 +146,14 @@ namespace Duplicati.Library.Main.Operation.Restore Stopwatch? sw_request = options.InternalProfiling ? new() : null; Stopwatch? sw_wakeup = options.InternalProfiling ? new() : null; + void handle_add(long volume_id, VolumeWrapper volume) + { + cache[volume_id] = volume; + cache_size += volume.Size; + cache_size_max_consumed = Math.Max(cache_size_max_consumed, cache_size); + cache_last_touched.Add(volume_id); + } + void handle_evict(long volume_id) { Logging.Log.WriteExplicitMessage(LOGTAG, "VolumeRequest", "Evicting volume {0} from cache", volume_id); @@ -259,9 +267,7 @@ namespace Duplicati.Library.Main.Operation.Restore evict_lru(); } Logging.Log.WriteExplicitMessage(LOGTAG, "VolumeRequest", "Caching volume {0} ({1} + {2} <= {3})", volume_id, cache_size, volume.Size, cache_max); - cache[volume_id] = volume; - cache_size += volume.Size; - cache_size_max_consumed = Math.Max(cache_size_max_consumed, cache_size); + handle_add(volume_id, volume); } else { @@ -282,11 +288,8 @@ namespace Duplicati.Library.Main.Operation.Restore Logging.Log.WriteWarningMessage(LOGTAG, "CacheExhausted", null, "Restore volume cache is empty but disk space in '{0}' is still below the configured minimum. Performance impact is likely.", temp_dir); } Logging.Log.WriteExplicitMessage(LOGTAG, "VolumeRequest", "Caching volume {0} in unlimited mode (free space: {1})", volume_id, available_free_space); - cache[volume_id] = volume; - cache_size += volume.Size; - cache_size_max_consumed = Math.Max(cache_size_max_consumed, cache_size); + handle_add(volume_id, volume); } - cache_last_touched.Add(volume_id); sw_cache_set?.Stop(); sw_wakeup?.Start(); foreach (var request in in_flight_downloads[volume_id])