diff options
author | warwickmm <warwickmm@users.noreply.github.com> | 2022-04-17 05:44:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-17 05:44:24 +0300 |
commit | de13cbcbd0f85492e8b8603def0ced7d7472a8e4 (patch) | |
tree | 0a13ec4a8b2f3f7474ad9c00807226081ccf1dab | |
parent | 737cbcde2a28ae2988e5e9fa0a098318031595f4 (diff) | |
parent | 15ccf8130a16a93d06e29521d3c90fbc6b11771a (diff) |
Merge pull request #4703 from albertony/ignore_invalid_accesstime
Ignore exception when file access time is not valid
-rw-r--r-- | Duplicati/Library/Common/IO/SystemIOWindows.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Duplicati/Library/Common/IO/SystemIOWindows.cs b/Duplicati/Library/Common/IO/SystemIOWindows.cs index adf797d2a..343dcb78e 100644 --- a/Duplicati/Library/Common/IO/SystemIOWindows.cs +++ b/Duplicati/Library/Common/IO/SystemIOWindows.cs @@ -508,7 +508,19 @@ namespace Duplicati.Library.Common.IO public IFileEntry FileEntry(string path)
{
var fileInfo = new FileInfo(AddExtendedDevicePathPrefix(path));
- return new FileEntry(fileInfo.Name, fileInfo.Length, fileInfo.LastAccessTime, fileInfo.LastWriteTime);
+ var lastAccess = new DateTime();
+ try
+ {
+ // Internally this will convert the FILETIME value from Windows API to a
+ // DateTime. If the value represents a date after 12/31/9999 it will throw
+ // ArgumentOutOfRangeException, because this is not supported by DateTime.
+ // Some file systems seem to set strange access timestamps on files, which
+ // may lead to this exception being thrown. Since the last accessed
+ // timestamp is not important such exeptions are just silently ignored.
+ lastAccess = fileInfo.LastAccessTime;
+ }
+ catch { }
+ return new FileEntry(fileInfo.Name, fileInfo.Length, lastAccess, fileInfo.LastWriteTime);
}
public Dictionary<string, string> GetMetadata(string path, bool isSymlink, bool followSymlink)
|