Merge pull request #1333 from DarthGizka/stability-fixes-20230630

Fix typo in ValidatorUtils::readInteger(), fix accident-prone file list loop & exempt missing files from processing
This commit is contained in:
Grahame Grieve 2023-07-07 14:41:59 +10:00 committed by GitHub
commit cacf6696cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View File

@ -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 // 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 // something that should've been loaded
for (SourceFile ref : refs) { for (SourceFile ref : refs) {
if (ref.isProcess() || all) { if (ref.isProcess() || all && !ref.isKnownToBeMissing()) {
ref.setCnt(igLoader.loadContent(ref.getRef(), "validate", false, first)); ref.setCnt(igLoader.loadContent(ref.getRef(), "validate", false, first));
if (loader != null && ref.getCnt() != null) { if (loader != null && ref.getCnt() != null) {
try { try {

View File

@ -69,6 +69,9 @@ public class ValidatorUtils {
public void setCnt(Content cnt) { public void setCnt(Content cnt) {
this.cnt = cnt; this.cnt = cnt;
} }
public boolean isKnownToBeMissing () {
return date == 0; // File::lastModified() returns 0 if the file is missing
}
} }
protected static void grabNatives(Map<String, byte[]> source, Map<String, byte[]> binaries, String prefix) { protected static void grabNatives(Map<String, byte[]> source, Map<String, byte[]> binaries, String prefix) {
@ -181,11 +184,10 @@ public class ValidatorUtils {
if (file.isFile()) { if (file.isFile()) {
addSourceFile(refs, file); addSourceFile(refs, file);
} else { } else {
for (int i = 0; i < file.listFiles().length; i++) { for (File fileInDirectory : file.listFiles()) {
File[] fileList = file.listFiles(); if (fileInDirectory.isFile()) {
if (fileList[i].isFile()) { if (!Utilities.isIgnorableFile(fileInDirectory)) {
if (!Utilities.isIgnorableFile(fileList[i])) { addSourceFile(refs, fileInDirectory);
addSourceFile(refs, fileList[i]);
} }
} }
} }
@ -196,9 +198,9 @@ public class ValidatorUtils {
private static SourceFile addSourceFile(List<SourceFile> refs, File file) { private static SourceFile addSourceFile(List<SourceFile> refs, File file) {
SourceFile src = addSourceFile(refs, file.getPath()); 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) { if (src.date != l) {
src.setProcess(true); src.setProcess(l != 0); // process only if not missing
} }
src.date = l; src.date = l;
return src; return src;

View File

@ -427,11 +427,11 @@ public class Params {
return cliContext; return cliContext;
} }
private static int readInteger(String n, String v) { private static int readInteger(String name, String value) {
if (!Utilities.isInteger(v)) { if (!Utilities.isInteger(value)) {
throw new Error("Unable to read "+v+" provided for '"+n+"' - must be an integer"); 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) { private static ValidatorWatchMode readWatchMode(String s) {
@ -485,4 +485,4 @@ public class Params {
} }
} }
} }
} }