mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-12-27 10:57:45 +01:00
cleanup orphaned config nodes
This commit is contained in:
parent
ae8d9052a4
commit
fe62b96c4a
@ -409,11 +409,20 @@ public class ConfigSection extends MemoryConfiguration {
|
||||
addDefault(path, value);
|
||||
} else {
|
||||
createNodePath(path, false);
|
||||
Object last = null;
|
||||
synchronized (root.lock) {
|
||||
if (value != null) {
|
||||
root.changed |= root.values.put(fullPath + path, value) != value;
|
||||
root.changed |= (last = root.values.put(fullPath + path, value)) != value;
|
||||
} else {
|
||||
root.changed |= root.values.remove(fullPath + path) != null;
|
||||
root.changed |= (last = root.values.remove(fullPath + path)) != null;
|
||||
}
|
||||
}
|
||||
if (last != value && last != null && last instanceof ConfigSection) {
|
||||
// clean up orphaned nodes
|
||||
final String trim = fullPath + path + root.pathChar;
|
||||
synchronized (root.lock) {
|
||||
root.values.keySet().stream().filter(k -> k.startsWith(trim)).collect(Collectors.toSet()).stream()
|
||||
.forEach(k -> root.values.remove(k));
|
||||
}
|
||||
}
|
||||
onChange();
|
||||
|
Loading…
Reference in New Issue
Block a user