core-3nweb-client-lib 0.53.6 → 0.53.8
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.
- package/build/api-defs/files.d.ts +4 -2
- package/build/core/storage/synced/obj-files.js +9 -8
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +17 -9
- package/build/lib-client/objs-on-disk/obj-on-disk.js +53 -20
- package/build/lib-client/xsp-fs/folder-node.js +1 -9
- package/build/lib-client/xsp-fs/fs.js +32 -16
- package/package.json +1 -1
|
@@ -637,7 +637,8 @@ declare namespace web3n.files {
|
|
|
637
637
|
status(skipServerCheck?: boolean): Promise<SyncStatus>;
|
|
638
638
|
|
|
639
639
|
/**
|
|
640
|
-
* Returns a state of on-disk cache
|
|
640
|
+
* Returns a state of on-disk cache of file, also checking on-disk state of base version(s), when
|
|
641
|
+
* given one has it.
|
|
641
642
|
* @param version
|
|
642
643
|
*/
|
|
643
644
|
isRemoteVersionOnDisk(
|
|
@@ -1438,7 +1439,8 @@ declare namespace web3n.files {
|
|
|
1438
1439
|
status(path: string, skipServerCheck?: boolean): Promise<SyncStatus>;
|
|
1439
1440
|
|
|
1440
1441
|
/**
|
|
1441
|
-
* Returns a state of on-disk cache of an item in fs
|
|
1442
|
+
* Returns a state of on-disk cache of an item in fs, also checking on-disk state of base version(s), when
|
|
1443
|
+
* given one has it.
|
|
1442
1444
|
* @param version
|
|
1443
1445
|
*/
|
|
1444
1446
|
isRemoteVersionOnDisk(path: string, version: number): Promise<'partial'|'complete'|'none'>;
|
|
@@ -191,19 +191,19 @@ class SyncedObj {
|
|
|
191
191
|
this.scheduleGC = scheduleGC;
|
|
192
192
|
this.remoteVers = (0, timed_cache_1.makeTimedCache)(60 * 1000);
|
|
193
193
|
this.localVers = (0, timed_cache_1.makeTimedCache)(60 * 1000);
|
|
194
|
-
this.localAndSyncedObjSegsGetterFromDisk = async (v, ofs, len) => {
|
|
194
|
+
this.localAndSyncedObjSegsGetterFromDisk = async (v, ofs, len, infoOnly) => {
|
|
195
195
|
const latestSynced = this.status.latestSyncedVersion();
|
|
196
196
|
if (latestSynced && (latestSynced >= v)) {
|
|
197
|
-
return this.remoteObjSegsGetterFromDisk(v, ofs, len);
|
|
197
|
+
return this.remoteObjSegsGetterFromDisk(v, ofs, len, infoOnly);
|
|
198
198
|
}
|
|
199
199
|
let objVer = this.localVers.get(v);
|
|
200
200
|
if (!objVer) {
|
|
201
201
|
objVer = await obj_on_disk_1.ObjOnDisk.forExistingFile(this.objId, v, this.localVerPath(v), this.downloader, this.localAndSyncedObjSegsGetterFromDisk);
|
|
202
202
|
this.localVers.set(v, objVer);
|
|
203
203
|
}
|
|
204
|
-
return objVer.readSegsOnlyFromDisk(ofs, len);
|
|
204
|
+
return (infoOnly ? objVer.getSegsInfo(ofs, len) : objVer.readSegsOnlyFromDisk(ofs, len));
|
|
205
205
|
};
|
|
206
|
-
this.remoteObjSegsGetterFromDisk = async (v, ofs, len) => {
|
|
206
|
+
this.remoteObjSegsGetterFromDisk = async (v, ofs, len, infoOnly) => {
|
|
207
207
|
let objVer = this.remoteVers.get(v);
|
|
208
208
|
if (!objVer) {
|
|
209
209
|
try {
|
|
@@ -218,7 +218,7 @@ class SyncedObj {
|
|
|
218
218
|
return [{ type: 'new', thisVerOfs: ofs, len }];
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
return objVer.readSegsOnlyFromDisk(ofs, len);
|
|
221
|
+
return (infoOnly ? objVer.getSegsInfo(ofs, len) : objVer.readSegsOnlyFromDisk(ofs, len));
|
|
222
222
|
};
|
|
223
223
|
Object.freeze(this);
|
|
224
224
|
}
|
|
@@ -412,7 +412,8 @@ class SyncedObj {
|
|
|
412
412
|
return 'none';
|
|
413
413
|
}
|
|
414
414
|
const objVer = await this.instanceOfRemoteObjVer(version);
|
|
415
|
-
|
|
415
|
+
const segsNotInVerFiles = await objVer.segsNotInVersionFiles();
|
|
416
|
+
return ((segsNotInVerFiles.length > 0) ? 'partial' : 'complete');
|
|
416
417
|
}
|
|
417
418
|
async getNumOfBytesNeedingDownload(version) {
|
|
418
419
|
if (!this.status.isAmongRemoteOrSynced(version)) {
|
|
@@ -428,11 +429,11 @@ class SyncedObj {
|
|
|
428
429
|
return 'unknown';
|
|
429
430
|
}
|
|
430
431
|
const objVer = await this.instanceOfRemoteObjVer(version);
|
|
431
|
-
return objVer.numOfBytesNeedingDownload();
|
|
432
|
+
return await objVer.numOfBytesNeedingDownload();
|
|
432
433
|
}
|
|
433
434
|
async startDownloadProcess(version, eventSink) {
|
|
434
435
|
const objVer = await this.instanceOfRemoteObjVer(version);
|
|
435
|
-
const downloadTaskId = objVer.startDownloadInBackground(eventSink);
|
|
436
|
+
const downloadTaskId = await objVer.startDownloadInBackground(eventSink);
|
|
436
437
|
return (downloadTaskId ? { downloadTaskId } : undefined);
|
|
437
438
|
}
|
|
438
439
|
}
|
|
@@ -3,9 +3,16 @@ import { ObjSource, Subscribe, Layout } from 'xsp-files';
|
|
|
3
3
|
import { FileWrite } from './file-writing-proc';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import { ObjVersionFile } from '../../lib-common/objs-on-disk/obj-version-file';
|
|
6
|
-
import { NotOnDiskFiniteChunk, FiniteChunk } from '../../lib-common/objs-on-disk/file-layout';
|
|
6
|
+
import { NotOnDiskFiniteChunk, BaseSegsChunk, FiniteChunk, OnDiskChunk, NewSegsChunk } from '../../lib-common/objs-on-disk/file-layout';
|
|
7
7
|
import { DiffInfo } from '../../lib-common/service-api/3nstorage/owner';
|
|
8
|
-
export type GetBaseSegsOnDisk = (version: number, ofs: number, len: number) => Promise<(Uint8Array |
|
|
8
|
+
export type GetBaseSegsOnDisk = (version: number, ofs: number, len: number, onlyInfo: boolean) => Promise<(Uint8Array | SegsChunkPlaceInfo)[]>;
|
|
9
|
+
export type SegsChunkPlaceInfo = OnDiskChunk | ChunkInBaseFiles | NewSegsChunk | BaseSegsChunk;
|
|
10
|
+
export interface ChunkInBaseFiles {
|
|
11
|
+
type: 'base-in-files';
|
|
12
|
+
thisVerOfs: number;
|
|
13
|
+
len: number;
|
|
14
|
+
baseVerOfs: number;
|
|
15
|
+
}
|
|
9
16
|
export declare class ObjOnDisk {
|
|
10
17
|
readonly objId: ObjId;
|
|
11
18
|
readonly version: number;
|
|
@@ -32,6 +39,8 @@ export declare class ObjOnDisk {
|
|
|
32
39
|
private readSegs;
|
|
33
40
|
private downloads;
|
|
34
41
|
readSegsOnlyFromDisk(offset: number, len: number): Promise<(Uint8Array | NotOnDiskFiniteChunk)[]>;
|
|
42
|
+
private getBaseSegsOrInfo;
|
|
43
|
+
getSegsInfo(offset: number, len: number): Promise<SegsChunkPlaceInfo[]>;
|
|
35
44
|
private readBaseBytesFromOtherFilesOnDisk;
|
|
36
45
|
getSrc(): ObjSource;
|
|
37
46
|
getBaseVersion(): number | undefined;
|
|
@@ -40,24 +49,23 @@ export declare class ObjOnDisk {
|
|
|
40
49
|
diff: DiffInfo;
|
|
41
50
|
newSegsPackOrder: FiniteChunk[];
|
|
42
51
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
startDownloadInBackground(eventSink: DownloadEventSink): number | undefined;
|
|
52
|
+
segsNotInVersionFiles(): Promise<NotOnDiskFiniteChunk[]>;
|
|
53
|
+
numOfBytesNeedingDownload(): Promise<number>;
|
|
54
|
+
startDownloadInBackground(eventSink: DownloadEventSink): Promise<number | undefined>;
|
|
47
55
|
}
|
|
48
56
|
export declare class Download {
|
|
49
57
|
readonly objId: ObjId;
|
|
50
58
|
readonly version: number;
|
|
51
59
|
private readonly downloader;
|
|
52
60
|
saveSegs?: ObjVersionFile["saveSegs"] | undefined;
|
|
53
|
-
|
|
61
|
+
segsNotInVersionFiles?: ObjOnDisk["segsNotInVersionFiles"] | undefined;
|
|
54
62
|
private readonly segsAsapRequest;
|
|
55
63
|
private initDataRequest;
|
|
56
64
|
private inBkgrnd;
|
|
57
|
-
constructor(objId: ObjId, version: number, downloader: ObjDownloader, saveSegs?: ObjVersionFile["saveSegs"] | undefined,
|
|
65
|
+
constructor(objId: ObjId, version: number, downloader: ObjDownloader, saveSegs?: ObjVersionFile["saveSegs"] | undefined, segsNotInVersionFiles?: ObjOnDisk["segsNotInVersionFiles"] | undefined);
|
|
58
66
|
getInitParts(): Promise<InitDownloadParts>;
|
|
59
67
|
downloadAndSaveSegsChunk(chunk: NotOnDiskFiniteChunk): Promise<Uint8Array>;
|
|
60
|
-
downloadAllInBackground(eventSink: DownloadEventSink): number | undefined
|
|
68
|
+
downloadAllInBackground(eventSink: DownloadEventSink): Promise<number | undefined>;
|
|
61
69
|
nextActionType(): {
|
|
62
70
|
runASAP: boolean;
|
|
63
71
|
} | undefined;
|
|
@@ -39,7 +39,7 @@ class ObjOnDisk {
|
|
|
39
39
|
this.proxiedHeader = undefined;
|
|
40
40
|
if (this.downloadsInProgress) {
|
|
41
41
|
this.downloadsInProgress.saveSegs = this.objFile.saveSegs.bind(this.objFile);
|
|
42
|
-
this.downloadsInProgress.
|
|
42
|
+
this.downloadsInProgress.segsNotInVersionFiles = this.segsNotInVersionFiles.bind(this);
|
|
43
43
|
}
|
|
44
44
|
Object.seal(this);
|
|
45
45
|
}
|
|
@@ -127,7 +127,7 @@ class ObjOnDisk {
|
|
|
127
127
|
if (!this.downloader) {
|
|
128
128
|
throw new Error(`Object ${this.objId}, version ${this.version}, is not on a disk.`);
|
|
129
129
|
}
|
|
130
|
-
this.downloadsInProgress = new Download(this.objId, this.version, this.downloader, this.objFile.saveSegs.bind(this.objFile), this.
|
|
130
|
+
this.downloadsInProgress = new Download(this.objId, this.version, this.downloader, this.objFile.saveSegs.bind(this.objFile), this.segsNotInVersionFiles.bind(this));
|
|
131
131
|
}
|
|
132
132
|
return this.downloadsInProgress;
|
|
133
133
|
}
|
|
@@ -148,7 +148,7 @@ class ObjOnDisk {
|
|
|
148
148
|
}
|
|
149
149
|
return bytesAndChunks;
|
|
150
150
|
}
|
|
151
|
-
async
|
|
151
|
+
async getBaseSegsOrInfo(ofs, len, onlyInfo) {
|
|
152
152
|
const baseVersion = this.objFile.getBaseVersion();
|
|
153
153
|
if (baseVersion === undefined) {
|
|
154
154
|
throw new Error(`File for object ${this.objId}, version ${this.version} points to base, but base is not set`);
|
|
@@ -156,7 +156,43 @@ class ObjOnDisk {
|
|
|
156
156
|
if (!this.getBaseSegsOnDisk) {
|
|
157
157
|
throw new Error(`Object ${this.objId}, version ${this.version} doesn't have a getter of base source`);
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
return await this.getBaseSegsOnDisk(baseVersion, ofs, len, onlyInfo);
|
|
160
|
+
}
|
|
161
|
+
async getSegsInfo(offset, len) {
|
|
162
|
+
const segsLocations = this.objFile.segsLocations(offset, len);
|
|
163
|
+
const segsInfo = [];
|
|
164
|
+
for (const chunk of segsLocations) {
|
|
165
|
+
if (chunk.type !== 'base') {
|
|
166
|
+
segsInfo.push(chunk);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const chunksFromBase = await this.getBaseSegsOrInfo(chunk.baseVerOfs, chunk.len, true);
|
|
170
|
+
let thisVerOfs = chunk.thisVerOfs;
|
|
171
|
+
let baseVerOfs = chunk.baseVerOfs;
|
|
172
|
+
for (const chunkFromBase of chunksFromBase) {
|
|
173
|
+
let isInFiles;
|
|
174
|
+
switch (chunkFromBase.type) {
|
|
175
|
+
case 'base':
|
|
176
|
+
case 'new':
|
|
177
|
+
isInFiles = false;
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
isInFiles = true;
|
|
181
|
+
}
|
|
182
|
+
segsInfo.push({
|
|
183
|
+
type: (isInFiles ? 'base-in-files' : 'base'),
|
|
184
|
+
len: chunkFromBase.len,
|
|
185
|
+
thisVerOfs,
|
|
186
|
+
baseVerOfs
|
|
187
|
+
});
|
|
188
|
+
thisVerOfs += len;
|
|
189
|
+
baseVerOfs += len;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return segsInfo;
|
|
193
|
+
}
|
|
194
|
+
async readBaseBytesFromOtherFilesOnDisk(chunk) {
|
|
195
|
+
const baseBytesAndChunks = await this.getBaseSegsOrInfo(chunk.baseVerOfs, chunk.len, false);
|
|
160
196
|
// now we should convert new->base, adjusting all offsets, cause all those
|
|
161
197
|
// labels are relative to base version, and we need 'em to be relative to
|
|
162
198
|
// this version
|
|
@@ -200,35 +236,32 @@ class ObjOnDisk {
|
|
|
200
236
|
diffFromBase() {
|
|
201
237
|
return this.objFile.diffFromBase();
|
|
202
238
|
}
|
|
203
|
-
|
|
239
|
+
async segsNotInVersionFiles() {
|
|
204
240
|
const totalLen = this.objFile.getTotalSegsLen();
|
|
205
|
-
const
|
|
206
|
-
return
|
|
207
|
-
}
|
|
208
|
-
doesFileNeedDownload() {
|
|
209
|
-
return (this.segsThatNeedDownload().length !== 0);
|
|
241
|
+
const segsInfo = await this.getSegsInfo(0, totalLen);
|
|
242
|
+
return segsInfo.filter(({ type }) => ((type === 'new') || (type === 'base')));
|
|
210
243
|
}
|
|
211
|
-
numOfBytesNeedingDownload() {
|
|
244
|
+
async numOfBytesNeedingDownload() {
|
|
212
245
|
let totalLen = 0;
|
|
213
|
-
for (const { len } of this.
|
|
246
|
+
for (const { len } of await this.segsNotInVersionFiles()) {
|
|
214
247
|
totalLen += len;
|
|
215
248
|
}
|
|
216
249
|
return totalLen;
|
|
217
250
|
}
|
|
218
|
-
startDownloadInBackground(eventSink) {
|
|
219
|
-
return this.downloads().downloadAllInBackground(eventSink);
|
|
251
|
+
async startDownloadInBackground(eventSink) {
|
|
252
|
+
return await this.downloads().downloadAllInBackground(eventSink);
|
|
220
253
|
}
|
|
221
254
|
}
|
|
222
255
|
exports.ObjOnDisk = ObjOnDisk;
|
|
223
256
|
Object.freeze(ObjOnDisk.prototype);
|
|
224
257
|
Object.freeze(ObjOnDisk);
|
|
225
258
|
class Download {
|
|
226
|
-
constructor(objId, version, downloader, saveSegs,
|
|
259
|
+
constructor(objId, version, downloader, saveSegs, segsNotInVersionFiles) {
|
|
227
260
|
this.objId = objId;
|
|
228
261
|
this.version = version;
|
|
229
262
|
this.downloader = downloader;
|
|
230
263
|
this.saveSegs = saveSegs;
|
|
231
|
-
this.
|
|
264
|
+
this.segsNotInVersionFiles = segsNotInVersionFiles;
|
|
232
265
|
this.segsAsapRequest = [];
|
|
233
266
|
this.initDataRequest = undefined;
|
|
234
267
|
this.inBkgrnd = undefined;
|
|
@@ -269,14 +302,14 @@ class Download {
|
|
|
269
302
|
this.downloader.schedule(this);
|
|
270
303
|
return deferred.promise;
|
|
271
304
|
}
|
|
272
|
-
downloadAllInBackground(eventSink) {
|
|
273
|
-
if (!this.
|
|
305
|
+
async downloadAllInBackground(eventSink) {
|
|
306
|
+
if (!this.segsNotInVersionFiles) {
|
|
274
307
|
throw new Error(`segsThatNeedDownload is not initialized`);
|
|
275
308
|
}
|
|
276
309
|
if (this.inBkgrnd) {
|
|
277
310
|
return this.inBkgrnd.downloadTaskId;
|
|
278
311
|
}
|
|
279
|
-
const chunks = this.
|
|
312
|
+
const chunks = await this.segsNotInVersionFiles();
|
|
280
313
|
if (chunks.length === 0) {
|
|
281
314
|
return;
|
|
282
315
|
}
|
|
@@ -386,7 +419,7 @@ class Download {
|
|
|
386
419
|
return;
|
|
387
420
|
}
|
|
388
421
|
if (!this.inBkgrnd.chunks) {
|
|
389
|
-
this.inBkgrnd.chunks = this.
|
|
422
|
+
this.inBkgrnd.chunks = await this.segsNotInVersionFiles();
|
|
390
423
|
if (this.inBkgrnd.chunks.length === 0) {
|
|
391
424
|
this.completeBkgrnd();
|
|
392
425
|
return;
|
|
@@ -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,10 +664,10 @@ 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
|
-
const item = { nameInParent: event.path, parent
|
|
670
|
+
const item = { nameInParent: event.path, parent };
|
|
671
671
|
this.map.set(objId, item);
|
|
672
672
|
return pathOfMapItem(item);
|
|
673
673
|
}
|
|
@@ -676,30 +676,39 @@ class ObjIdToPathMap {
|
|
|
676
676
|
recursivelyRemoveFromMap(this.map, objId, objPathItem);
|
|
677
677
|
return;
|
|
678
678
|
}
|
|
679
|
-
if ((this.maxDepth !== undefined) && (this.maxDepth <= objPathItem
|
|
679
|
+
if ((this.maxDepth !== undefined) && (this.maxDepth <= depthOf(objPathItem))) {
|
|
680
680
|
return;
|
|
681
681
|
}
|
|
682
682
|
if (event.type === 'entry-renaming') {
|
|
683
683
|
const childEntry = this.map.get(childObjId);
|
|
684
684
|
if (childEntry) {
|
|
685
|
-
childEntry.nameInParent
|
|
685
|
+
childEntry.nameInParent = event.newName;
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
else if (event.type === 'entry-removal') {
|
|
689
689
|
const childEntry = this.map.get(childObjId);
|
|
690
|
-
|
|
691
|
-
|
|
690
|
+
// Context: FolderNode.moveChildTo() does move with addition first, therefore,
|
|
691
|
+
// if removal is part of move, parent will be different
|
|
692
|
+
if (((childEntry === null || childEntry === void 0 ? void 0 : childEntry.parent) === objPathItem) && (childEntry.nameInParent === event.name)) {
|
|
693
|
+
recursivelyRemoveFromMap(this.map, childObjId, childEntry);
|
|
692
694
|
}
|
|
693
695
|
}
|
|
694
696
|
else if (event.type === 'entry-addition') {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
697
|
+
// Context: FolderNode.moveChildTo() does move with addition first, therefore,
|
|
698
|
+
// child may exist, and only its parent need change
|
|
699
|
+
const childEntry = this.map.get(childObjId);
|
|
700
|
+
if (childEntry) {
|
|
701
|
+
childEntry.parent = objPathItem;
|
|
702
|
+
childEntry.nameInParent = event.entry.name;
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
const childEntry = { parent: objPathItem, nameInParent: event.entry.name };
|
|
706
|
+
this.map.set(childObjId, childEntry);
|
|
707
|
+
// XXX if childEntry is a folder with its own children, subtree should be added
|
|
708
|
+
// if (event.entry.isFolder && (!this.maxDepth || (depthOf(childEntry) < this.maxDepth))) {
|
|
709
|
+
// await recursivelyAddIntoMap(this.map, childNode, childEntry, this.maxDepth, childEntry.depth+1);
|
|
710
|
+
// }
|
|
711
|
+
}
|
|
703
712
|
}
|
|
704
713
|
}
|
|
705
714
|
copyWithLongPath(nodeEvent) {
|
|
@@ -712,7 +721,7 @@ Object.freeze(ObjIdToPathMap);
|
|
|
712
721
|
async function recursivelyAddIntoMap(map, parentNode, parent, maxDepth, depth) {
|
|
713
722
|
const { lst } = parentNode.list();
|
|
714
723
|
for (const item of lst) {
|
|
715
|
-
const childItem = {
|
|
724
|
+
const childItem = { parent, nameInParent: item.name };
|
|
716
725
|
if (item.isFile || item.isLink) {
|
|
717
726
|
const { objId } = parentNode.getCurrentNodeInfo(item.name);
|
|
718
727
|
map.set(objId, childItem);
|
|
@@ -747,6 +756,13 @@ function pathOfMapItem(item) {
|
|
|
747
756
|
return item.nameInParent;
|
|
748
757
|
}
|
|
749
758
|
}
|
|
759
|
+
function depthOf(item) {
|
|
760
|
+
let depth = 0;
|
|
761
|
+
for (let p = item.parent; p; p = p.parent) {
|
|
762
|
+
depth += 1;
|
|
763
|
+
}
|
|
764
|
+
return depth;
|
|
765
|
+
}
|
|
750
766
|
function shallowCopyWithPath(event, path) {
|
|
751
767
|
const shallowCopy = {};
|
|
752
768
|
for (const [field, value] of Object.entries(event)) {
|