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
// 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 {

View File

@ -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<String, byte[]> source, Map<String, byte[]> 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<SourceFile> 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;

View File

@ -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 {
}
}
}
}
}