Changed all file timestamps to read utc directly instead of converting from local time

This commit is contained in:
Kenneth Skovhede
2014-02-27 14:14:48 +01:00
parent f4a5f4d54e
commit 8e6b034173
6 changed files with 21 additions and 23 deletions
@@ -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);
@@ -33,13 +33,13 @@ namespace Duplicati.Library.Snapshots
/// </summary>
/// <param name="callback">The callback to invoke with each found path</param>
IEnumerable<string> EnumerateFilesAndFolders(Duplicati.Library.Utility.Utility.EnumerationFilterDelegate callback);
/// <summary>
/// Gets the last write time of a given file
/// Gets the last write time of a given file in UTC
/// </summary>
/// <param name="file">The full path to the file in non-snapshot format</param>
/// <returns>The last write time of the file</returns>
DateTime GetLastWriteTime(string file);
DateTime GetLastWriteTimeUtc(string file);
/// <summary>
/// Opens a file for reading
+4 -5
View File
@@ -399,17 +399,16 @@ namespace Duplicati.Library.Snapshots
s => Utility.Utility.EnumerateFileSystemEntries(s.Key, callback, this.ListFolders, this.ListFiles, this.GetAttributes)
);
}
/// <summary>
/// Gets the last write time of a given file
/// Gets the last write time of a given file in UTC
/// </summary>
/// <param name="file">The full path to the file in non-snapshot format</param>
/// <returns>The last write time of the file</returns>
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));
}
/// <summary>
/// Opens a file for reading
/// </summary>
+3 -3
View File
@@ -107,13 +107,13 @@ namespace Duplicati.Library.Snapshots
}
/// <summary>
/// Gets the last write time of a given file
/// Gets the last write time of a given file in UTC
/// </summary>
/// <param name="file">The full path to the file in non-snapshot format</param>
/// <returns>The last write time of the file</returns>
public virtual DateTime GetLastWriteTime(string file)
public virtual DateTime GetLastWriteTimeUtc(string file)
{
return System.IO.File.GetLastWriteTime(file);
return System.IO.File.GetLastWriteTimeUtc(file);
}
/// <summary>
@@ -70,17 +70,17 @@ namespace Duplicati.Library.Snapshots
}
/// <summary>
/// Gets the last write time of a given file
/// Gets the last write time of a given file in UTC
/// </summary>
/// <param name="file">The full path to the file in non-snapshot format</param>
/// <returns>The last write time of the file</returns>
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));
}
/// <summary>
@@ -301,23 +301,22 @@ namespace Duplicati.Library.Snapshots
}
/// <summary>
/// Gets the last write time of a given file
/// Gets the last write time of a given file in UTC
/// </summary>
/// <param name="file">The full path to the file in non-shadow format</param>
/// <returns>The last write time of the file</returns>
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));
}
/// <summary>
/// Opens a file for reading
/// </summary>