MCPcopy Index your code
hub / github.com/Acode-Foundation/Acode / getAllFiles

Function getAllFiles

src/lib/fileList.js:264–296  ·  view source on GitHub ↗

* Get all file recursively * @param {Tree} parent - An array to store files * @param {Tree} [root] - Root path

(parent, root, options = {})

Source from the content-addressed store, hash-verified

262 * @param {Tree} [root] - Root path
263 */
264async function getAllFiles(parent, root, options = {}) {
265 root = root || parent.root;
266 if (!parent.children || !root.isConnected) return;
267
268 if (supportsNativeWorkspace(root.url)) {
269 return getAllFilesNative(parent, root, options);
270 }
271
272 try {
273 const entries = await fsOperation(parent.url).lsDir();
274 const promises = [];
275
276 for (const item of entries) {
277 promises.push(createChildTree(parent, item, root));
278 }
279
280 await Promise.all(promises);
281 } catch (error) {
282 // retry after 3s
283 parent.retriedCount += 1;
284 if (parent.retriedCount > settings.value.maxRetryCount) return;
285 if (settings.value.showRetryToast) {
286 toast(`retrying: ${parent.path}`);
287 }
288
289 setTimeout(() => {
290 // why not outside? because parent may be removed
291 if (!root.isConnected) return;
292 parent.children.length = 0;
293 getAllFiles(parent, root, options);
294 }, 3000);
295 }
296}
297
298function supportsNativeWorkspace(url = "") {
299 return (

Callers 5

appendFunction · 0.85
refreshFunction · 0.85
addRootFunction · 0.85
createChildTreeFunction · 0.85
updateMethod · 0.85

Calls 5

supportsNativeWorkspaceFunction · 0.85
getAllFilesNativeFunction · 0.85
fsOperationFunction · 0.85
createChildTreeFunction · 0.85
lsDirMethod · 0.45

Tested by

no test coverage detected