X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/5b54915209ce26d977d9dabb97001ac06b24441a..265e32dee6f3d92dfde7ede23e3baa2d831923b3:/src/com/owncloud/android/files/services/IndexedForest.java diff --git a/src/com/owncloud/android/files/services/IndexedForest.java b/src/com/owncloud/android/files/services/IndexedForest.java index daf46a56..52482993 100644 --- a/src/com/owncloud/android/files/services/IndexedForest.java +++ b/src/com/owncloud/android/files/services/IndexedForest.java @@ -23,6 +23,7 @@ import com.owncloud.android.datamodel.OCFile; import java.io.File; import java.util.HashSet; +import java.util.Iterator; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -128,6 +129,10 @@ public class IndexedForest { Node firstRemoved = mMap.remove(targetKey); if (firstRemoved != null) { + /// remove children + removeDescendants(firstRemoved); + + /// remove ancestors if only here due to firstRemoved Node removed = firstRemoved; Node parent = removed.getParent(); while (parent != null) { @@ -149,6 +154,16 @@ public class IndexedForest { } + private void removeDescendants(Node removed) { + Iterator> childrenIt = removed.getChildren().iterator(); + Node child = null; + while (childrenIt.hasNext()) { + child = childrenIt.next(); + mMap.remove(child.getKey()); + removeDescendants(child); + } + } + public boolean contains(Account account, String remotePath) { String targetKey = buildKey(account, remotePath); return mMap.containsKey(targetKey);