Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralbertony <12441419+albertony@users.noreply.github.com>2022-04-02 21:28:09 +0300
committeralbertony <12441419+albertony@users.noreply.github.com>2022-04-02 21:56:20 +0300
commit15ccf8130a16a93d06e29521d3c90fbc6b11771a (patch)
tree594c858501ea9fe175bf63faf7e2e77c5c142088
parent2f3b0e83a0c3e5dbdd8ccba0a08e3623d64ca231 (diff)
Ignore exception when file access time is not valid
When getting the value from FileSystemInfo.LastAccessTime, it will internally 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 exceptions are now just silently ignored.
-rw-r--r--Duplicati/Library/Common/IO/SystemIOWindows.cs14
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)