Details
-
Type: Bug
-
Status: Closed (View Workflow)
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.7
-
Component/s: o.c.common.progress
-
Labels:None
Description
I noticed zip failures when installing certain zips from Xiphos a long time ago but have only just worked out the problem.
Here is a typical error:
java.net.MalformedURLException: The URL /mnt/sdcard/Android/data/net.bible.android.activity/files/modules/genbook/rawgenbook/luthersworks could not be created as a directory.
at org.crosswire.common.util.IOUtil.unpackZip(IOUtil.java:78)
at org.crosswire.jsword.book.install.sword.AbstractSwordInstaller$1.run(AbstractSwordInstaller.java:258)
The problem is that this zip contains dir entries and if you look in the second half of IOUtil.unpackZip starting from
URI child = NetUtil.getURI(entryFile);
you will see that unpackZip code tries to create a file even if the ZipEntry is a dir, and when the dir is created as a file later attempts to unzip real files into the file (which should be a dir) fail.
One simple fix is to wrap the last part of code in "if (!entry.isDirectory()) {" as below:
if (!entry.isDirectory()) {
URI child = NetUtil.getURI(entryFile);
OutputStream dataOut = NetUtil.getOutputStream(child);
InputStream dataIn = zf.getInputStream(entry);
while (true) {
int count = dataIn.read(dbuf);
if (count == -1)
dataOut.write(dbuf, 0, count);
}
dataOut.close();
}
I am thinking of checking in some of these recent fixes if you have no objections?