- String currentPath = remotePath, parentPath = null, parentKey = null;
- Node<V> currentNode = valuedNode, parentNode = null;
- boolean linked = false;
- while (!OCFile.ROOT_PATH.equals(currentPath) && !linked) {
- parentPath = new File(currentPath).getParent();
- if (!parentPath.endsWith(OCFile.PATH_SEPARATOR)) {
- parentPath += OCFile.PATH_SEPARATOR;
+ } else {
+ // value really added
+ String currentPath = remotePath, parentPath = null, parentKey = null;
+ Node<V> currentNode = valuedNode, parentNode = null;
+ boolean linked = false;
+ while (!OCFile.ROOT_PATH.equals(currentPath) && !linked) {
+ parentPath = new File(currentPath).getParent();
+ if (!parentPath.endsWith(OCFile.PATH_SEPARATOR)) {
+ parentPath += OCFile.PATH_SEPARATOR;
+ }
+ parentKey = buildKey(account, parentPath);
+ parentNode = mMap.get(parentKey);
+ if (parentNode == null) {
+ parentNode = new Node(parentKey, null);
+ parentNode.addChild(currentNode);
+ mMap.put(parentKey, parentNode);
+ } else {
+ parentNode.addChild(currentNode);
+ linked = true;
+ }
+ currentPath = parentPath;
+ currentNode = parentNode;