AddonInfoAddonsXmlProvider check for missing folder (#3903)

* [AddonInfoAddonsXmlProvider] fix issue #3901

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green 2023-12-07 13:30:10 +00:00 committed by GitHub
parent 44b92dbc59
commit de9912d06b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,8 +79,18 @@ public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
}
private void initialize() {
File fileFolder = new File(folder);
try {
if (!fileFolder.isDirectory()) {
logger.debug("Folder '{}' does not exist", folder);
return;
}
} catch (SecurityException e) {
logger.warn("Folder '{}' threw a security exception: {}", folder, e.getMessage());
return;
}
AddonInfoListReader reader = new AddonInfoListReader();
Stream.of(new File(folder).listFiles()).filter(f -> f.isFile() && f.getName().endsWith(".xml")).forEach(f -> {
Stream.of(fileFolder.listFiles()).filter(f -> f.isFile() && f.getName().endsWith(".xml")).forEach(f -> {
try {
String xml = Files.readString(f.toPath());
if (xml != null && !xml.isBlank()) {
@ -94,6 +104,8 @@ public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
logger.warn("File '{}' has invalid content", f.getName());
} catch (XStreamException e) {
logger.warn("File '{}' could not be deserialized", f.getName());
} catch (SecurityException e) {
logger.warn("File '{}' threw a security exception: {}", folder, e.getMessage());
}
});
}