From 2b23a71288792c003ec285237cbb8af6280b08fb Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 2 Jun 2020 14:33:08 -0400 Subject: [PATCH 1/2] ProductUpgrader: be extra careful about a copy loop Signed-off-by: Derrick Stolee --- GVFS/GVFS.Common/ProductUpgrader.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/GVFS/GVFS.Common/ProductUpgrader.cs b/GVFS/GVFS.Common/ProductUpgrader.cs index 2acda0c791..231b613a71 100644 --- a/GVFS/GVFS.Common/ProductUpgrader.cs +++ b/GVFS/GVFS.Common/ProductUpgrader.cs @@ -184,7 +184,14 @@ public virtual bool TrySetupUpgradeApplicationDirectory(out string upgradeApplic // and its contents into C:\Program Files\GVFS\ProgramData\GVFS.Upgrade\Tools). The exclusion below is // added to avoid this loop. HashSet directoriesToExclude = new HashSet(); - directoriesToExclude.Add(GVFSPlatform.Instance.GetSecureDataRootForGVFS()); + + string secureDataRoot = GVFSPlatform.Instance.GetSecureDataRootForGVFS(); + directoriesToExclude.Add(secureDataRoot); + directoriesToExclude.Add(upgradeApplicationDirectory); + + this.tracer.RelatedInfo($"Copying contents of '{currentPath}' to '{upgradeApplicationDirectory}'," + + $"excluding '{upgradeApplicationDirectory}' and '{secureDataRoot}'"); + this.fileSystem.CopyDirectoryRecursive(currentPath, upgradeApplicationDirectory, directoriesToExclude); } catch (UnauthorizedAccessException e) From 5119adb3998b76b7bfa63d4e9092c60cccea1d75 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 2 Jun 2020 14:42:41 -0400 Subject: [PATCH 2/2] ProductUpgrader: use OrdinalIgnoreCase in exluded HashSet Signed-off-by: Derrick Stolee --- GVFS/GVFS.Common/ProductUpgrader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GVFS/GVFS.Common/ProductUpgrader.cs b/GVFS/GVFS.Common/ProductUpgrader.cs index 231b613a71..ff722f8a61 100644 --- a/GVFS/GVFS.Common/ProductUpgrader.cs +++ b/GVFS/GVFS.Common/ProductUpgrader.cs @@ -183,7 +183,7 @@ public virtual bool TrySetupUpgradeApplicationDirectory(out string upgradeApplic // directory causes a cycle(at some point we start copying C:\Program Files\GVFS\ProgramData\GVFS.Upgrade // and its contents into C:\Program Files\GVFS\ProgramData\GVFS.Upgrade\Tools). The exclusion below is // added to avoid this loop. - HashSet directoriesToExclude = new HashSet(); + HashSet directoriesToExclude = new HashSet(StringComparer.OrdinalIgnoreCase); string secureDataRoot = GVFSPlatform.Instance.GetSecureDataRootForGVFS(); directoriesToExclude.Add(secureDataRoot);