提交 01348d08 authored 作者: Thomas Mueller's avatar Thomas Mueller

File system bugfixes

上级 8d934127
...@@ -57,7 +57,11 @@ public class FilePathZip extends FilePath { ...@@ -57,7 +57,11 @@ public class FilePathZip extends FilePath {
return true; return true;
} }
ZipFile file = openZipFile(); ZipFile file = openZipFile();
try {
return file.getEntry(entryName) != null; return file.getEntry(entryName) != null;
} finally {
file.close();
}
} catch (IOException e) { } catch (IOException e) {
return false; return false;
} }
...@@ -93,6 +97,7 @@ public class FilePathZip extends FilePath { ...@@ -93,6 +97,7 @@ public class FilePathZip extends FilePath {
return true; return true;
} }
ZipFile file = openZipFile(); ZipFile file = openZipFile();
try {
Enumeration<? extends ZipEntry> en = file.entries(); Enumeration<? extends ZipEntry> en = file.entries();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {
ZipEntry entry = en.nextElement(); ZipEntry entry = en.nextElement();
...@@ -107,6 +112,9 @@ public class FilePathZip extends FilePath { ...@@ -107,6 +112,9 @@ public class FilePathZip extends FilePath {
} }
} }
} }
} finally {
file.close();
}
return false; return false;
} catch (IOException e) { } catch (IOException e) {
return false; return false;
...@@ -127,8 +135,12 @@ public class FilePathZip extends FilePath { ...@@ -127,8 +135,12 @@ public class FilePathZip extends FilePath {
public long size() { public long size() {
try { try {
ZipFile file = openZipFile(); ZipFile file = openZipFile();
try {
ZipEntry entry = file.getEntry(getEntryName()); ZipEntry entry = file.getEntry(getEntryName());
return entry == null ? 0 : entry.getSize(); return entry == null ? 0 : entry.getSize();
} finally {
file.close();
}
} catch (IOException e) { } catch (IOException e) {
return 0; return 0;
} }
...@@ -146,6 +158,7 @@ public class FilePathZip extends FilePath { ...@@ -146,6 +158,7 @@ public class FilePathZip extends FilePath {
path += "/"; path += "/";
} }
ZipFile file = openZipFile(); ZipFile file = openZipFile();
try {
String dirName = getEntryName(); String dirName = getEntryName();
String prefix = path.substring(0, path.length() - dirName.length()); String prefix = path.substring(0, path.length() - dirName.length());
Enumeration<? extends ZipEntry> en = file.entries(); Enumeration<? extends ZipEntry> en = file.entries();
...@@ -163,6 +176,9 @@ public class FilePathZip extends FilePath { ...@@ -163,6 +176,9 @@ public class FilePathZip extends FilePath {
list.add(getPath(prefix + name)); list.add(getPath(prefix + name));
} }
} }
} finally {
file.close();
}
return list; return list;
} catch (IOException e) { } catch (IOException e) {
throw DbException.convertIOException(e, "listFiles " + path); throw DbException.convertIOException(e, "listFiles " + path);
...@@ -179,6 +195,7 @@ public class FilePathZip extends FilePath { ...@@ -179,6 +195,7 @@ public class FilePathZip extends FilePath {
ZipFile file = openZipFile(); ZipFile file = openZipFile();
ZipEntry entry = file.getEntry(getEntryName()); ZipEntry entry = file.getEntry(getEntryName());
if (entry == null) { if (entry == null) {
file.close();
throw new FileNotFoundException(name); throw new FileNotFoundException(name);
} }
return new FileZip(file, entry); return new FileZip(file, entry);
...@@ -368,6 +385,7 @@ class FileZip extends FileBase { ...@@ -368,6 +385,7 @@ class FileZip extends FileBase {
in.close(); in.close();
in = null; in = null;
} }
file.close();
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论