MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / addNativeEntries

Function addNativeEntries

src/lib/fileList.js:360–383  ·  view source on GitHub ↗
(root, entries)

Source from the content-addressed store, hash-verified

358}
359
360function addNativeEntries(root, entries) {
361 for (const item of entries) {
362 const parentUrl = item.parentUrl || item.parent;
363 const parentTree =
364 parentUrl === root.url ? root : getTree([root], parentUrl);
365 if (!parentTree?.children) continue;
366 if (parentTree.children.find(({ url }) => url === item.url)) continue;
367
368 const file = new Tree(
369 item.name,
370 item.url,
371 item.isDirectory,
372 item.mime || item.type,
373 item.size,
374 item.modifiedDate,
375 );
376 parentTree.children.push(file);
377
378 if (!file.children) {
379 emit("push-file", file);
380 emit("add-file", file);
381 }
382 }
383}
384
385/**
386 * Emit an event

Callers 1

getAllFilesNativeFunction · 0.85

Calls 2

getTreeFunction · 0.85
emitFunction · 0.70

Tested by

no test coverage detected