mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-12-28 11:28:08 +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);
|
addDefault(path, value);
|
||||||
} else {
|
} else {
|
||||||
createNodePath(path, false);
|
createNodePath(path, false);
|
||||||
|
Object last = null;
|
||||||
synchronized (root.lock) {
|
synchronized (root.lock) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
root.changed |= root.values.put(fullPath + path, value) != value;
|
root.changed |= (last = root.values.put(fullPath + path, value)) != value;
|
||||||
} else {
|
} 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();
|
onChange();
|
||||||
|
Loading…
Reference in New Issue
Block a user