mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
AddonInfoAddonsXmlProvider check for missing folder (#3903)
* [AddonInfoAddonsXmlProvider] fix issue #3901 Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
44b92dbc59
commit
de9912d06b
@ -79,8 +79,18 @@ public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
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();
|
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 {
|
try {
|
||||||
String xml = Files.readString(f.toPath());
|
String xml = Files.readString(f.toPath());
|
||||||
if (xml != null && !xml.isBlank()) {
|
if (xml != null && !xml.isBlank()) {
|
||||||
@ -94,6 +104,8 @@ public class AddonInfoAddonsXmlProvider implements AddonInfoProvider {
|
|||||||
logger.warn("File '{}' has invalid content", f.getName());
|
logger.warn("File '{}' has invalid content", f.getName());
|
||||||
} catch (XStreamException e) {
|
} catch (XStreamException e) {
|
||||||
logger.warn("File '{}' could not be deserialized", f.getName());
|
logger.warn("File '{}' could not be deserialized", f.getName());
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
logger.warn("File '{}' threw a security exception: {}", folder, e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user