From a5cfeff912a0f4c71de1b7e5ded657ac4da2ccf8 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 14 Aug 2018 14:42:51 +0200 Subject: [PATCH] Removed the one-element cache to avoid potential race conditions. Rewrote the path mapping to use simpler operations. This is a potential fix for #3307 --- Duplicati/Library/Snapshots/WindowsSnapshot.cs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Duplicati/Library/Snapshots/WindowsSnapshot.cs b/Duplicati/Library/Snapshots/WindowsSnapshot.cs index f466f69cf..b9b49746c 100644 --- a/Duplicati/Library/Snapshots/WindowsSnapshot.cs +++ b/Duplicati/Library/Snapshots/WindowsSnapshot.cs @@ -409,19 +409,9 @@ namespace Duplicati.Library.Snapshots throw new InvalidOperationException(); } - /// - /// Cache element to speed up returning the same paths - /// - private KeyValuePair m_lastLookup; - /// public override string ConvertToSnapshotPath(string localPath) { - // Hot cache, we tend to call the same conversion multiple times - var m = m_lastLookup; - if (m.Key == localPath) - return m.Value; - if (!Path.IsPathRooted(localPath)) throw new InvalidOperationException(); @@ -430,12 +420,11 @@ namespace Duplicati.Library.Snapshots throw new InvalidOperationException(); // Note: Do NOT use Path.Combine as it strips the UNC path prefix - var subPath = localPath.Replace(root, String.Empty); + var subPath = localPath.Substring(root.Length); if (!volumePath.EndsWith(SLASH, StringComparison.Ordinal) && !subPath.StartsWith(SLASH, StringComparison.Ordinal)) - subPath = subPath.Insert(0, SLASH); + volumePath += SLASH; - var mappedPath = subPath.Insert(0, volumePath); - m_lastLookup = new KeyValuePair(localPath, mappedPath); + var mappedPath = volumePath + subPath; return mappedPath; }