Skip to content

Commit 29ad1cf

Browse files
committed
Persistence upgrader: Fix unmanaged config not respected
Signed-off-by: Florian Hotze <dev@florianhotze.com>
1 parent a221c4f commit 29ad1cf

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

tools/upgradetool/src/main/java/org/openhab/core/tools/internal/PersistenceUpgrader.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ public boolean execute(@Nullable Path userdataPath, @Nullable Path confPath) {
6565
return false;
6666
}
6767

68+
List<String> unmanagedConfigs;
6869
List<String> managedConfigs;
6970
try {
70-
managedConfigs = managedPersistenceConfigs(installedPersistenceAddons(userdataPath),
71-
unmanagedPersistenceConfigs(confPath));
71+
unmanagedConfigs = unmanagedPersistenceConfigs(confPath);
72+
managedConfigs = managedPersistenceConfigs(installedPersistenceAddons(userdataPath), unmanagedConfigs);
7273
} catch (IOException e) {
7374
logger.error("{} skipped: failed to read config: {}", getName(), e.getMessage());
7475
return false;
@@ -77,6 +78,10 @@ public boolean execute(@Nullable Path userdataPath, @Nullable Path confPath) {
7778
// No managed persistence configurations, so no need to upgrade
7879
return true;
7980
}
81+
logger.debug("found {} managed persistence configurations: {}", managedConfigs.size(),
82+
String.join(",", managedConfigs));
83+
logger.debug("found {} unmanaged persistence configurations: {}", unmanagedConfigs.size(),
84+
String.join(",", unmanagedConfigs));
8085

8186
Path persistenceJsonDatabasePath = userdataPath
8287
.resolve(Path.of("jsondb", "org.openhab.core.persistence.PersistenceServiceConfiguration.json"));
@@ -165,8 +170,8 @@ private List<String> installedPersistenceAddons(Path userdataPath) throws IOExce
165170
private List<String> unmanagedPersistenceConfigs(Path configPath) throws IOException {
166171
Path persistenceConfigPath = configPath.resolve("persistence");
167172
try (Stream<Path> files = Files.list(persistenceConfigPath)) {
168-
return files.filter(configFile -> configFile.endsWith(".persist"))
169-
.map(configFile -> configFile.getFileName().toString().replace(".persist", "")).toList();
173+
return files.map(f -> f.getFileName().toString()).filter(f -> f.endsWith(".persist"))
174+
.map(f -> f.replace(".persist", "")).toList();
170175
}
171176
}
172177

0 commit comments

Comments
 (0)