Avoid opening 0 byte test files as real archives

This commit is contained in:
Reinhard Pointner 2016-10-21 02:22:35 +08:00
parent dcf3c4931c
commit 565555e0b3
1 changed files with 10 additions and 4 deletions

View File

@ -104,14 +104,20 @@ public class ScriptShellMethods {
return ARCHIVE_FILES.accept(self);
}
public static boolean isDisk(File self) throws Exception {
public static boolean isDisk(File self) {
// check disk folder
if (self.isDirectory() && MediaDetection.isDiskFolder(self))
if (self.isDirectory() && MediaDetection.isDiskFolder(self)) {
return true;
}
// check disk image
if (self.isFile() && MediaTypes.getDefaultFilter("video/iso").accept(self) && MediaDetection.isVideoDiskFile(self))
return true;
if (self.isFile() && MediaTypes.getDefaultFilter("video/iso").accept(self)) {
try {
return MediaDetection.isVideoDiskFile(self);
} catch (Exception e) {
debug.log(Level.WARNING, format("Failed to read disk image: %s: %s", self, e));
}
}
return false;
}