380034 last modified times taken from JarEntry for JarFile resources

This commit is contained in:
Greg Wilkins 2012-05-22 15:05:29 +02:00
parent d436400db1
commit ca2a040a39
2 changed files with 15 additions and 0 deletions

View File

@ -228,7 +228,11 @@ class JarFileResource extends JarResource
public long lastModified()
{
if (checkConnection() && _file!=null)
{
if (exists() && _entry!=null)
return _entry.getTime();
return _file.lastModified();
}
return -1;
}

View File

@ -25,6 +25,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
@ -310,6 +311,16 @@ public class ResourceTest
assertFalse(jarFileResource.isContainedIn(container));
}
/* ------------------------------------------------------------ */
@Test
public void testJarFileLastModified ()
throws Exception
{
String s = "jar:"+__userURL+"TestData/test.zip!/subdir/numbers";
Resource r = Resource.newResource(s);
assertEquals(971425252000L,r.lastModified()); // Known date value inside zip
}
/* ------------------------------------------------------------ */
@Test
public void testJarFileCopyToDirectoryTraversal () throws Exception