core-3nweb-client-lib 0.53.6 → 0.53.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -170,7 +170,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
170
170
|
this.setUpdatedParams(src.version, attrs, xattrs);
|
|
171
171
|
}
|
|
172
172
|
async adoptRemote(opts) {
|
|
173
|
-
|
|
173
|
+
await this.doChange(true, async () => {
|
|
174
174
|
try {
|
|
175
175
|
const adopted = await this.syncedStorage().adoptRemote(this.objId, opts);
|
|
176
176
|
if (!adopted) {
|
|
@@ -193,19 +193,11 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
193
193
|
const event = this.makeEntryRenamingEvent(this.version, 'sync', newName, oldName);
|
|
194
194
|
this.broadcastEvent(event, false, objId);
|
|
195
195
|
}
|
|
196
|
-
return removedNodes;
|
|
197
196
|
}
|
|
198
197
|
catch (exc) {
|
|
199
198
|
throw (0, common_1.setPathInExc)(exc, this.name);
|
|
200
199
|
}
|
|
201
200
|
});
|
|
202
|
-
if (!objsToRm) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
for (const objToRm of objsToRm) {
|
|
206
|
-
const nodeToRm = await this.getOrMakeChildNodeForInfo(objToRm);
|
|
207
|
-
this.callRemoveObjOn('sync', nodeToRm);
|
|
208
|
-
}
|
|
209
201
|
}
|
|
210
202
|
makeEntryAdditionEvent(newVersion, src, node, moveLabel) {
|
|
211
203
|
const event = {
|
|
@@ -644,7 +644,7 @@ class ObjIdToPathMap {
|
|
|
644
644
|
Object.seal(this);
|
|
645
645
|
}
|
|
646
646
|
async fillFromTree(root) {
|
|
647
|
-
const rootItem = {
|
|
647
|
+
const rootItem = { nameInParent: '.' };
|
|
648
648
|
this.map.set(root.objId, rootItem);
|
|
649
649
|
await recursivelyAddIntoMap(this.map, root, rootItem, this.maxDepth, 1);
|
|
650
650
|
}
|
|
@@ -664,11 +664,17 @@ class ObjIdToPathMap {
|
|
|
664
664
|
if (!parent) {
|
|
665
665
|
return;
|
|
666
666
|
}
|
|
667
|
-
if ((this.maxDepth !== undefined) && (this.maxDepth <= parent
|
|
667
|
+
if ((this.maxDepth !== undefined) && (this.maxDepth <= depthOf(parent))) {
|
|
668
668
|
return;
|
|
669
669
|
}
|
|
670
|
-
|
|
671
|
-
|
|
670
|
+
let item = this.map.get(objId);
|
|
671
|
+
if (item) {
|
|
672
|
+
item.parent = parent;
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
item = { nameInParent: event.path, parent };
|
|
676
|
+
this.map.set(objId, item);
|
|
677
|
+
}
|
|
672
678
|
return pathOfMapItem(item);
|
|
673
679
|
}
|
|
674
680
|
updateFoundObjMapOnEvent(objId, objPathItem, childObjId, event) {
|
|
@@ -676,7 +682,7 @@ class ObjIdToPathMap {
|
|
|
676
682
|
recursivelyRemoveFromMap(this.map, objId, objPathItem);
|
|
677
683
|
return;
|
|
678
684
|
}
|
|
679
|
-
if ((this.maxDepth !== undefined) && (this.maxDepth <= objPathItem
|
|
685
|
+
if ((this.maxDepth !== undefined) && (this.maxDepth <= depthOf(objPathItem))) {
|
|
680
686
|
return;
|
|
681
687
|
}
|
|
682
688
|
if (event.type === 'entry-renaming') {
|
|
@@ -687,19 +693,28 @@ class ObjIdToPathMap {
|
|
|
687
693
|
}
|
|
688
694
|
else if (event.type === 'entry-removal') {
|
|
689
695
|
const childEntry = this.map.get(childObjId);
|
|
690
|
-
|
|
691
|
-
|
|
696
|
+
// Context: FolderNode.moveChildTo() does move with addition first, therefore,
|
|
697
|
+
// if removal is part of move, parent will be different
|
|
698
|
+
if (((childEntry === null || childEntry === void 0 ? void 0 : childEntry.parent) === objPathItem) && (childEntry.nameInParent === event.name)) {
|
|
699
|
+
recursivelyRemoveFromMap(this.map, childObjId, childEntry);
|
|
692
700
|
}
|
|
693
701
|
}
|
|
694
702
|
else if (event.type === 'entry-addition') {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
+
// Context: FolderNode.moveChildTo() does move with addition first, therefore,
|
|
704
|
+
// child may exist, and only its parent need change
|
|
705
|
+
const childEntry = this.map.get(childObjId);
|
|
706
|
+
if (childEntry) {
|
|
707
|
+
childEntry.parent = objPathItem;
|
|
708
|
+
childEntry.nameInParent = event.entry.name;
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
const childEntry = { parent: objPathItem, nameInParent: event.entry.name };
|
|
712
|
+
this.map.set(objId, childEntry);
|
|
713
|
+
// XXX if childEntry is a folder with its own children, subtree should be added
|
|
714
|
+
// if (event.entry.isFolder && (!this.maxDepth || (depthOf(childEntry) < this.maxDepth))) {
|
|
715
|
+
// await recursivelyAddIntoMap(this.map, childNode, childEntry, this.maxDepth, childEntry.depth+1);
|
|
716
|
+
// }
|
|
717
|
+
}
|
|
703
718
|
}
|
|
704
719
|
}
|
|
705
720
|
copyWithLongPath(nodeEvent) {
|
|
@@ -712,7 +727,7 @@ Object.freeze(ObjIdToPathMap);
|
|
|
712
727
|
async function recursivelyAddIntoMap(map, parentNode, parent, maxDepth, depth) {
|
|
713
728
|
const { lst } = parentNode.list();
|
|
714
729
|
for (const item of lst) {
|
|
715
|
-
const childItem = {
|
|
730
|
+
const childItem = { parent, nameInParent: item.name };
|
|
716
731
|
if (item.isFile || item.isLink) {
|
|
717
732
|
const { objId } = parentNode.getCurrentNodeInfo(item.name);
|
|
718
733
|
map.set(objId, childItem);
|
|
@@ -747,6 +762,13 @@ function pathOfMapItem(item) {
|
|
|
747
762
|
return item.nameInParent;
|
|
748
763
|
}
|
|
749
764
|
}
|
|
765
|
+
function depthOf(item) {
|
|
766
|
+
let depth = 0;
|
|
767
|
+
for (let p = item.parent; p; p = p.parent) {
|
|
768
|
+
depth += 1;
|
|
769
|
+
}
|
|
770
|
+
return depth;
|
|
771
|
+
}
|
|
750
772
|
function shallowCopyWithPath(event, path) {
|
|
751
773
|
const shallowCopy = {};
|
|
752
774
|
for (const [field, value] of Object.entries(event)) {
|