diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java index 338f36537..9eac91ec4 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidationEngine.java @@ -588,7 +588,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP // available for other resources to depend on. if it fails to load, there'll be an error if there's // something that should've been loaded for (SourceFile ref : refs) { - if (ref.isProcess() || all) { + if (ref.isProcess() || all && !ref.isKnownToBeMissing()) { ref.setCnt(igLoader.loadContent(ref.getRef(), "validate", false, first)); if (loader != null && ref.getCnt() != null) { try { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorUtils.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorUtils.java index 3609d20aa..139374f77 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorUtils.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/ValidatorUtils.java @@ -69,6 +69,9 @@ public class ValidatorUtils { public void setCnt(Content cnt) { this.cnt = cnt; } + public boolean isKnownToBeMissing () { + return date == 0; // File::lastModified() returns 0 if the file is missing + } } protected static void grabNatives(Map source, Map binaries, String prefix) { @@ -181,11 +184,10 @@ public class ValidatorUtils { if (file.isFile()) { addSourceFile(refs, file); } else { - for (int i = 0; i < file.listFiles().length; i++) { - File[] fileList = file.listFiles(); - if (fileList[i].isFile()) { - if (!Utilities.isIgnorableFile(fileList[i])) { - addSourceFile(refs, fileList[i]); + for (File fileInDirectory : file.listFiles()) { + if (fileInDirectory.isFile()) { + if (!Utilities.isIgnorableFile(fileInDirectory)) { + addSourceFile(refs, fileInDirectory); } } } @@ -196,9 +198,9 @@ public class ValidatorUtils { private static SourceFile addSourceFile(List refs, File file) { SourceFile src = addSourceFile(refs, file.getPath()); - Long l = file.lastModified(); + long l = file.lastModified(); // returns 0 if the file is missing if (src.date != l) { - src.setProcess(true); + src.setProcess(l != 0); // process only if not missing } src.date = l; return src; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java index 9be220576..013c528e0 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/cli/utils/Params.java @@ -427,11 +427,11 @@ public class Params { return cliContext; } - private static int readInteger(String n, String v) { - if (!Utilities.isInteger(v)) { - throw new Error("Unable to read "+v+" provided for '"+n+"' - must be an integer"); + private static int readInteger(String name, String value) { + if (!Utilities.isInteger(value)) { + throw new Error("Unable to read "+value+" provided for '"+name+"' - must be an integer"); } - return Integer.parseInt(n); + return Integer.parseInt(value); } private static ValidatorWatchMode readWatchMode(String s) { @@ -485,4 +485,4 @@ public class Params { } } } -} \ No newline at end of file +}