Regarding this JIRA issue:
-
http://jira.jboss.com/jira/browse/JBVFS-7
I created this test:
| public void testEntryModified() throws Exception
| {
| File tmp = File.createTempFile("testJarEntry", ".jar");
| Manifest mf = new Manifest();
| mf.getMainAttributes().putValue("Created-By", getClass().getName() +
"." + "testEntryModified");
| FileOutputStream fos = new FileOutputStream(tmp);
| JarOutputStream jos = new JarOutputStream(fos, mf);
| try
| {
| jos.setComment("testJarURLs");
| jos.setLevel(0);
| }
| finally
| {
| jos.close();
| }
| VFS vfs = VFS.getVFS(tmp.toURI());
| VirtualFile metainf = vfs.findChild("META-INF");
| List<VirtualFile> children = metainf.getChildren();
| assertEquals(1, children.size());
|
| fos = new FileOutputStream(tmp);
| jos = new JarOutputStream(fos, mf);
| try
| {
| ZipEntry entry = new ZipEntry("META-INF/some.txt");
| entry.setComment("some_comment");
| entry.setExtra("qwerty".getBytes());
| entry.setSize(1);
| jos.putNextEntry(entry);
| jos.closeEntry();
|
| entry = new ZipEntry("META-INF/other.txt");
| entry.setComment("other_comment");
| entry.setExtra("foobar".getBytes());
| entry.setSize(1);
| jos.putNextEntry(entry);
| jos.closeEntry();
| }
| finally
| {
| jos.close();
| }
|
| // vfs = VFS.getVFS(tmp.toURI());
| // metainf = vfs.findChild("META-INF");
| System.out.println("metainf = " + metainf.hasBeenModified());
| children = metainf.getChildren();
| assertEquals(3, children.size());
| }
|
Which looks legit, since when I uncomment two lines at the bottom, the new vfs handle
picks up all three entries.
But in our case, where we don't want to create new handle, but use the existing one,
where the handle should see that the content has changed and return 3 entries.
Of course that is not the case. :-(
And I don't see how you really do this in generic fashion w/o modifying all VFS, e.g.
lets say some 4level nested jar is updated.
Even in this case, where we have just simple jar, updating contents of META-INF handler is
far from trivial.
The handler that maps to META-INF is SynthenticDirEntryHandler, which only gets populated
when we iterate over entries of parent jar.
Meaning we would have to go back and recreate every entry.
And I don't know how much information that's needed for reconstruction we're
holding.
I'll have a look what can be done if I add some 'reconstruct' method to
VirtualFileHandler.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145853#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...