Skip to content

Commit

Permalink
PhysicalFileProvider: Remove second try on GetFileLinkTargetLastWrite…
Browse files Browse the repository at this point in the history
…TimeUtc (#57136)

* return the value from 2nd try

* Do not attempt a second try and just capture the FileNotFoundException

* Update src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Internal/FileSystemInfoHelper.cs

Co-authored-by: David Cantu <[email protected]>
Co-authored-by: Dan Moseley <[email protected]>
  • Loading branch information
3 people authored Aug 11, 2021
1 parent c59d200 commit 53b7ba9
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static bool IsExcluded(FileSystemInfo fileSystemInfo, ExclusionFilters fi
// If file is a link, and link target does not exists, return DateTime.MinValue
// since the link's LastWriteTimeUtc doesn't convey anything for this scenario.
// If file is not a link, return null to inform the caller that file is not a link.
public static DateTime? GetFileLinkTargetLastWriteTimeUtc(FileInfo fileInfo, bool isSecondTry = false)
public static DateTime? GetFileLinkTargetLastWriteTimeUtc(FileInfo fileInfo)
{
#if NETCOREAPP
Debug.Assert(fileInfo.Exists);
Expand All @@ -62,11 +62,6 @@ public static bool IsExcluded(FileSystemInfo fileSystemInfo, ExclusionFilters fi
catch (FileNotFoundException)
{
// The file ceased to exist between LinkTarget and ResolveLinkTarget.
// Try one more time, if it fails again just give up.
if (!isSecondTry)
{
GetFileLinkTargetLastWriteTimeUtc(fileInfo, isSecondTry: true);
}
}

return DateTime.MinValue;
Expand Down

0 comments on commit 53b7ba9

Please sign in to comment.