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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Matos <joao@tritao.eu>2016-06-17 20:19:19 +0300
committerJoão Matos <joao@tritao.eu>2016-06-17 20:23:05 +0300
commitbd938a4818edeaf72f3c1511dde976a20f9fc046 (patch)
tree44daa0bf13df79a3f89888c560c8d01c1888ad5c /mcs/class/System.IO.Compression
parent15fedcada9e4cbad652c623e9d5bb4fd591d457b (diff)
[System.IO.Compression] Fixed Zip entries with unset last write time to return the same as .NET.
.NET on Windows returns a fixed date for this, replicate the same behaviour in Mono. Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=40916. See also: https://github.com/NuGet/Home/issues/2518
Diffstat (limited to 'mcs/class/System.IO.Compression')
-rw-r--r--mcs/class/System.IO.Compression/SharpCompress/Common/Zip/ZipEntry.cs7
-rw-r--r--mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs12
-rw-r--r--mcs/class/System.IO.Compression/test.nupkgbin0 -> 5784 bytes
3 files changed, 19 insertions, 0 deletions
diff --git a/mcs/class/System.IO.Compression/SharpCompress/Common/Zip/ZipEntry.cs b/mcs/class/System.IO.Compression/SharpCompress/Common/Zip/ZipEntry.cs
index 6ed742eeca3..2c0ec07e784 100644
--- a/mcs/class/System.IO.Compression/SharpCompress/Common/Zip/ZipEntry.cs
+++ b/mcs/class/System.IO.Compression/SharpCompress/Common/Zip/ZipEntry.cs
@@ -16,6 +16,13 @@ namespace SharpCompress.Common.Zip
this.filePart = filePart;
lastModifiedTime = Utility.DosDateToDateTime(filePart.Header.LastModifiedDate,
filePart.Header.LastModifiedTime);
+ if (lastModifiedTime == default(DateTime))
+ {
+ // On .NET on Windows, for zip entries that don't have a last write time,
+ // the return value for ZipArchiveEntry.LastWriteTime is:
+ // 1/1/1980 12:00:00 AM, Ticks=624511296000000000
+ lastModifiedTime = new DateTime(624511296000000000);
+ }
}
}
diff --git a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs
index d461600299f..4205a1f40a0 100644
--- a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs
+++ b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs
@@ -264,6 +264,18 @@ namespace MonoTests.System.IO.Compression
}
[Test]
+ public void ZipEnumerateArchiveDefaultLastWriteTime()
+ {
+ using (var archive = new ZipArchive(File.Open("test.nupkg", FileMode.Open),
+ ZipArchiveMode.Read))
+ {
+ var entry = archive.GetEntry("_rels/.rels");
+ Assert.AreEqual(new DateTime(624511296000000000).Ticks, entry.LastWriteTime.Ticks);
+ Assert.IsNotNull(entry);
+ }
+ }
+
+ [Test]
public void ZipEnumerateEntriesReadMode()
{
File.Copy("archive.zip", "test.zip", overwrite: true);
diff --git a/mcs/class/System.IO.Compression/test.nupkg b/mcs/class/System.IO.Compression/test.nupkg
new file mode 100644
index 00000000000..0a7fe0575c0
--- /dev/null
+++ b/mcs/class/System.IO.Compression/test.nupkg
Binary files differ