Merge pull request #15468 from Bond-009/carefulWithLastMinChanges

Check if target exists before trying to follow it
This commit is contained in:
Joshua M. Boniface 2025-11-10 19:12:24 -05:00 committed by GitHub
commit 5878b1ffc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -92,6 +92,11 @@ public static class FileSystemHelper
return null;
}
if (!targetInfo.Exists)
{
return targetInfo;
}
var currentPath = targetInfo.FullName;
var visited = new HashSet<string>(StringComparer.Ordinal) { linkPath, currentPath };
while (File.ResolveLinkTarget(currentPath, returnFinalTarget: false) is FileInfo linkInfo)