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

Function handleGetFile

src/sidebarApps/searchInFiles/searchIndex.js:44–68  ·  view source on GitHub ↗
({ id, data })

Source from the content-addressed store, hash-verified

42 }
43
44 async function handleGetFile({ id, data }) {
45 const fileRequest = fileRequests.get(id);
46 if (fileRequest) return;
47 fileRequests.set(id, true);
48 const targetWorker = worker;
49
50 try {
51 const content = await readFile(data);
52 if (worker !== targetWorker || !targetWorker) return;
53 targetWorker.postMessage({
54 action: "get-file",
55 id,
56 data: content || "",
57 });
58 } catch (error) {
59 if (worker !== targetWorker || !targetWorker) return;
60 targetWorker.postMessage({
61 action: "get-file",
62 id,
63 error: error?.message || String(error),
64 });
65 } finally {
66 fileRequests.delete(id);
67 }
68 }
69
70 function post(action, data, expectResponse = false) {
71 const id = ++requestId;

Callers 1

getWorkerFunction · 0.85

Calls 5

StringInterface · 0.85
setMethod · 0.80
deleteMethod · 0.65
readFileFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected