Skip to content

Commit 1612722

Browse files
Merge pull request #1673: ProductUpgrader: be extra careful about a copy loop
The `ProductUpgrader` makes a backup of the `C:\Program Files\GVFS` folder before running the install, as a mechanism for backing out a failed upgrade. However, it copies that data into `C:\Program Files\GVFS\ProgramData\GVFS.Upgrade\Tools`, which can create a copy loop! This affected an actual user. I'm not sure why this affects that one user but not another. In addition to adding more defensive programming (adding the target of the copy to the list of exclusions), I also added some extra tracing so we can see how these strings differ on this machine. See #1672 for the master PR.
2 parents a05334b + 5119adb commit 1612722

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

GVFS/GVFS.Common/ProductUpgrader.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,15 @@ public virtual bool TrySetupUpgradeApplicationDirectory(out string upgradeApplic
183183
// directory causes a cycle(at some point we start copying C:\Program Files\GVFS\ProgramData\GVFS.Upgrade
184184
// and its contents into C:\Program Files\GVFS\ProgramData\GVFS.Upgrade\Tools). The exclusion below is
185185
// added to avoid this loop.
186-
HashSet<string> directoriesToExclude = new HashSet<string>();
187-
directoriesToExclude.Add(GVFSPlatform.Instance.GetSecureDataRootForGVFS());
186+
HashSet<string> directoriesToExclude = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
187+
188+
string secureDataRoot = GVFSPlatform.Instance.GetSecureDataRootForGVFS();
189+
directoriesToExclude.Add(secureDataRoot);
190+
directoriesToExclude.Add(upgradeApplicationDirectory);
191+
192+
this.tracer.RelatedInfo($"Copying contents of '{currentPath}' to '{upgradeApplicationDirectory}',"
193+
+ $"excluding '{upgradeApplicationDirectory}' and '{secureDataRoot}'");
194+
188195
this.fileSystem.CopyDirectoryRecursive(currentPath, upgradeApplicationDirectory, directoriesToExclude);
189196
}
190197
catch (UnauthorizedAccessException e)

0 commit comments

Comments
 (0)