Skip to content

Commit 389b6e1

Browse files
committed
[Xamarin.Android.Build.Tasks] Make use we use UTC Dates for ResolveLibraryProjectImports.cs
We were not using UTC for allot of the date time comparisons in the `ResolveLibraryProjectImports.cs` task. We really should be since it means we should not hit any issues with LocalTimes.
1 parent 6ae4b6b commit 389b6e1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void Extract (
186186

187187
// Skip already-extracted resources.
188188
var stamp = new FileInfo (Path.Combine (outdir.FullName, assemblyIdentName + ".stamp"));
189-
if (stamp.Exists && stamp.LastWriteTime > new FileInfo (assemblyPath).LastWriteTime) {
189+
if (stamp.Exists && stamp.LastWriteTimeUtc > new FileInfo (assemblyPath).LastWriteTimeUtc) {
190190
Log.LogDebugMessage ("Skipped resource lookup for {0}: extracted files are up to date", assemblyPath);
191191
#if SEPARATE_CRUNCH
192192
// FIXME: review these binResDir/binAssemblyDir thing and enable this. Eclipse does this.
@@ -211,7 +211,7 @@ void Extract (
211211
Directory.CreateDirectory (importsDir);
212212

213213
var assembly = res.GetAssembly (assemblyPath);
214-
var assemblyLastWrite = new FileInfo (assemblyPath).LastWriteTime;
214+
var assemblyLastWrite = new FileInfo (assemblyPath).LastWriteTimeUtc;
215215
bool updated = false;
216216

217217
foreach (var mod in assembly.Modules) {
@@ -223,7 +223,7 @@ void Extract (
223223
if (!Directory.Exists (outDirForDll))
224224
Directory.CreateDirectory (outDirForDll);
225225
var finfo = new FileInfo (Path.Combine (outDirForDll, envtxt.Name));
226-
if (!finfo.Exists || finfo.LastWriteTime > assemblyLastWrite) {
226+
if (!finfo.Exists || finfo.LastWriteTimeUtc > assemblyLastWrite) {
227227
using (var fs = finfo.Create ()) {
228228
var data = envtxt.GetResourceData ();
229229
fs.Write (data, 0, data.Length);
@@ -240,7 +240,7 @@ void Extract (
240240
foreach (var resjar in resjars) {
241241
var outjarFile = Path.Combine (importsDir, resjar.Name);
242242
var fi = new FileInfo (outjarFile);
243-
if (!fi.Exists || fi.LastWriteTime > assemblyLastWrite) {
243+
if (!fi.Exists || fi.LastWriteTimeUtc > assemblyLastWrite) {
244244
var data = resjar.GetResourceData ();
245245
using (var outfs = File.Create (outjarFile))
246246
outfs.Write (data, 0, data.Length);

src/Xamarin.Android.Build.Tasks/Utilities/Files.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ public static bool ExtractAll(ZipArchive zip, string destination, Action<int, in
223223
Directory.CreateDirectory (Path.Combine (destination, Path.GetDirectoryName (fullName)));
224224
var outfile = Path.GetFullPath (Path.Combine (destination, fullName));
225225
files.Add (outfile);
226-
var dt = File.Exists (outfile) ? File.GetLastWriteTimeUtc (outfile) : DateTime.MinValue;
226+
var isUtc = entry.ModificationTime.Kind == DateTimeKind.Utc;
227+
var dt = File.Exists (outfile) ? (isUtc ? File.GetLastWriteTimeUtc (outfile) : File.GetLastWriteTime (outfile) ) : DateTime.MinValue;
227228
if (forceUpdate || entry.ModificationTime > dt) {
228229
entry.Extract (destination, fullName, FileMode.OpenOrCreate);
229230
updated = true;

0 commit comments

Comments
 (0)