Scanner Fix (#2998)

This commit is contained in:
Joe Milazzo 2024-06-12 16:39:08 -05:00 committed by GitHub
parent 6139b3fbdf
commit 11635c6696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 78 additions and 4 deletions

View file

@ -745,12 +745,12 @@ public class DirectoryService : IDirectoryService
/// <summary>
/// Recursively scans a folder and returns the max last write time on any folders and files
/// </summary>
/// <remarks>If the folder is empty, this will return MaxValue for a DateTime</remarks>
/// <remarks>If the folder is empty or non-existant, this will return MaxValue for a DateTime</remarks>
/// <param name="folderPath"></param>
/// <returns>Max Last Write Time</returns>
public DateTime GetLastWriteTime(string folderPath)
{
if (!FileSystem.Directory.Exists(folderPath)) throw new IOException($"{folderPath} does not exist");
if (!FileSystem.Directory.Exists(folderPath)) return DateTime.MaxValue;
var fileEntries = FileSystem.Directory.GetFileSystemEntries(folderPath, "*.*", SearchOption.AllDirectories);
if (fileEntries.Length == 0) return DateTime.MaxValue;
return fileEntries.Max(path => FileSystem.File.GetLastWriteTime(path));