* added exists() to cached values in FastFile

This commit is contained in:
Reinhard Pointner 2009-05-03 17:38:22 +00:00
parent f4fa49e49b
commit a41f80bd9d
3 changed files with 13 additions and 4 deletions

View File

@ -9,7 +9,7 @@ import java.util.TreeMap;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
class AssociativeScriptObject implements Scriptable { public class AssociativeScriptObject implements Scriptable {
/** /**
* Map allowing look-up of values by a fault-tolerant key as specified by the defining key. * Map allowing look-up of values by a fault-tolerant key as specified by the defining key.

View File

@ -125,9 +125,7 @@ public class EpisodeFormatBindingBean {
@Define("crc32") @Define("crc32")
public String getCRC32() throws IOException, InterruptedException { public String getCRC32() throws IOException, InterruptedException {
// make sure media file is defined // use inferred media file (e.g. actual movie file instead of subtitle file)
checkMediaFile();
File inferredMediaFile = getInferredMediaFile(); File inferredMediaFile = getInferredMediaFile();
// try to get checksum from file name // try to get checksum from file name
@ -201,6 +199,9 @@ public class EpisodeFormatBindingBean {
@Define("inferredFile") @Define("inferredFile")
public File getInferredMediaFile() { public File getInferredMediaFile() {
// make sure media file is defined
checkMediaFile();
if (SUBTITLE_FILES.accept(mediaFile)) { if (SUBTITLE_FILES.accept(mediaFile)) {
// file is a subtitle // file is a subtitle
String name = FileUtilities.getName(mediaFile); String name = FileUtilities.getName(mediaFile);
@ -234,6 +235,7 @@ public class EpisodeFormatBindingBean {
MediaInfo newMediaInfo = new MediaInfo(); MediaInfo newMediaInfo = new MediaInfo();
// use inferred media file (e.g. actual movie file instead of subtitle file)
if (!newMediaInfo.open(getInferredMediaFile())) { if (!newMediaInfo.open(getInferredMediaFile())) {
throw new RuntimeException(String.format("Cannot open media file: %s", mediaFile)); throw new RuntimeException(String.format("Cannot open media file: %s", mediaFile));
} }

View File

@ -13,6 +13,7 @@ public class FastFile extends File {
private Long length; private Long length;
private Boolean isDirectory; private Boolean isDirectory;
private Boolean isFile; private Boolean isFile;
private Boolean exists;
public FastFile(String path) { public FastFile(String path) {
@ -31,6 +32,12 @@ public class FastFile extends File {
} }
@Override
public boolean exists() {
return exists != null ? exists : (exists = super.exists());
}
@Override @Override
public boolean isDirectory() { public boolean isDirectory() {
return isDirectory != null ? isDirectory : (isDirectory = super.isDirectory()); return isDirectory != null ? isDirectory : (isDirectory = super.isDirectory());