From 8e6b0341730bcbdfd6c809dda5307f3c7760d24e Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Thu, 27 Feb 2014 14:14:48 +0100 Subject: [PATCH] Changed all file timestamps to read utc directly instead of converting from local time --- Duplicati/Library/Main/Operation/BackupHandler.cs | 6 +++--- Duplicati/Library/Snapshots/ISnapshotService.cs | 6 +++--- Duplicati/Library/Snapshots/LinuxSnapshot.cs | 9 ++++----- Duplicati/Library/Snapshots/NoSnapshot.cs | 6 +++--- Duplicati/Library/Snapshots/NoSnapshotWindows.cs | 8 ++++---- Duplicati/Library/Snapshots/WindowsSnapshot.cs | 9 ++++----- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Duplicati/Library/Main/Operation/BackupHandler.cs b/Duplicati/Library/Main/Operation/BackupHandler.cs index 2be377eb5..497b4f6d5 100644 --- a/Duplicati/Library/Main/Operation/BackupHandler.cs +++ b/Duplicati/Library/Main/Operation/BackupHandler.cs @@ -616,7 +616,7 @@ namespace Duplicati.Library.Main.Operation if (!metadata.ContainsKey("CoreAttributes")) metadata["CoreAttributes"] = attributes.ToString(); if (!metadata.ContainsKey("CoreLastWritetime")) - metadata["CoreLastWritetime"] = m_snapshot.GetLastWriteTime(path).ToUniversalTime().Ticks.ToString(); + metadata["CoreLastWritetime"] = m_snapshot.GetLastWriteTimeUtc(path).Ticks.ToString(); } else { @@ -648,7 +648,7 @@ namespace Duplicati.Library.Main.Operation if (!metadata.ContainsKey("CoreAttributes")) metadata["CoreAttributes"] = attributes.ToString(); if (!metadata.ContainsKey("CoreLastWritetime")) - metadata["CoreLastWritetime"] = m_snapshot.GetLastWriteTime(path).ToUniversalTime().Ticks.ToString(); + metadata["CoreLastWritetime"] = m_snapshot.GetLastWriteTimeUtc(path).Ticks.ToString(); metahash = Utility.WrapMetadata(metadata, m_options); } else @@ -670,7 +670,7 @@ namespace Duplicati.Library.Main.Operation // Last scan time DateTime oldScanned; // Last file modification - DateTime lastModified = m_snapshot.GetLastWriteTime(path).ToUniversalTime(); + DateTime lastModified = m_snapshot.GetLastWriteTimeUtc(path); var oldId = m_database.GetFileEntry(path, out oldScanned); long filestatsize = m_snapshot.GetFileSize(path); diff --git a/Duplicati/Library/Snapshots/ISnapshotService.cs b/Duplicati/Library/Snapshots/ISnapshotService.cs index db9a9f206..9d0ab621d 100644 --- a/Duplicati/Library/Snapshots/ISnapshotService.cs +++ b/Duplicati/Library/Snapshots/ISnapshotService.cs @@ -33,13 +33,13 @@ namespace Duplicati.Library.Snapshots /// /// The callback to invoke with each found path IEnumerable EnumerateFilesAndFolders(Duplicati.Library.Utility.Utility.EnumerationFilterDelegate callback); - + /// - /// Gets the last write time of a given file + /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-snapshot format /// The last write time of the file - DateTime GetLastWriteTime(string file); + DateTime GetLastWriteTimeUtc(string file); /// /// Opens a file for reading diff --git a/Duplicati/Library/Snapshots/LinuxSnapshot.cs b/Duplicati/Library/Snapshots/LinuxSnapshot.cs index d9368e5d4..5590cfb45 100644 --- a/Duplicati/Library/Snapshots/LinuxSnapshot.cs +++ b/Duplicati/Library/Snapshots/LinuxSnapshot.cs @@ -399,17 +399,16 @@ namespace Duplicati.Library.Snapshots s => Utility.Utility.EnumerateFileSystemEntries(s.Key, callback, this.ListFolders, this.ListFiles, this.GetAttributes) ); } - + /// - /// Gets the last write time of a given file + /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-snapshot format /// The last write time of the file - public DateTime GetLastWriteTime(string file) + public DateTime GetLastWriteTimeUtc(string file) { - return System.IO.File.GetLastWriteTime(ConvertToSnapshotPath(FindSnapShotByLocalPath(file), file)); + return System.IO.File.GetLastWriteTimeUtc(ConvertToSnapshotPath(FindSnapShotByLocalPath(file), file)); } - /// /// Opens a file for reading /// diff --git a/Duplicati/Library/Snapshots/NoSnapshot.cs b/Duplicati/Library/Snapshots/NoSnapshot.cs index 924c92921..1500e6cc1 100644 --- a/Duplicati/Library/Snapshots/NoSnapshot.cs +++ b/Duplicati/Library/Snapshots/NoSnapshot.cs @@ -107,13 +107,13 @@ namespace Duplicati.Library.Snapshots } /// - /// Gets the last write time of a given file + /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-snapshot format /// The last write time of the file - public virtual DateTime GetLastWriteTime(string file) + public virtual DateTime GetLastWriteTimeUtc(string file) { - return System.IO.File.GetLastWriteTime(file); + return System.IO.File.GetLastWriteTimeUtc(file); } /// diff --git a/Duplicati/Library/Snapshots/NoSnapshotWindows.cs b/Duplicati/Library/Snapshots/NoSnapshotWindows.cs index e3ec8a1d7..5bf9a98da 100644 --- a/Duplicati/Library/Snapshots/NoSnapshotWindows.cs +++ b/Duplicati/Library/Snapshots/NoSnapshotWindows.cs @@ -70,17 +70,17 @@ namespace Duplicati.Library.Snapshots } /// - /// Gets the last write time of a given file + /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-snapshot format /// The last write time of the file - public override DateTime GetLastWriteTime (string file) + public override DateTime GetLastWriteTimeUtc (string file) { if (!SystemIOWindows.IsPathTooLong(file)) - try { return base.GetLastWriteTime(file); } + try { return base.GetLastWriteTimeUtc(file); } catch (System.IO.PathTooLongException) { } - return File.GetLastWriteTime(SystemIOWindows.PrefixWithUNC(file)); + return File.GetLastWriteTimeUtc(SystemIOWindows.PrefixWithUNC(file)); } /// diff --git a/Duplicati/Library/Snapshots/WindowsSnapshot.cs b/Duplicati/Library/Snapshots/WindowsSnapshot.cs index 3d1f9c3a7..35d8be32a 100644 --- a/Duplicati/Library/Snapshots/WindowsSnapshot.cs +++ b/Duplicati/Library/Snapshots/WindowsSnapshot.cs @@ -301,23 +301,22 @@ namespace Duplicati.Library.Snapshots } /// - /// Gets the last write time of a given file + /// Gets the last write time of a given file in UTC /// /// The full path to the file in non-shadow format /// The last write time of the file - public DateTime GetLastWriteTime(string file) + public DateTime GetLastWriteTimeUtc(string file) { string spath = GetSnapshotPath(file); if (!SystemIOWindows.IsPathTooLong(spath)) try { - return File.GetLastWriteTime(spath); + return File.GetLastWriteTimeUtc(spath); } catch (PathTooLongException) { } - return Alphaleonis.Win32.Filesystem.File.GetLastWriteTime(SystemIOWindows.PrefixWithUNC(spath)); + return Alphaleonis.Win32.Filesystem.File.GetLastWriteTimeUtc(SystemIOWindows.PrefixWithUNC(spath)); } - /// /// Opens a file for reading ///