MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / flushPending

Function flushPending

src/core/embedding-tracker.ts:85–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83 };
84
85 const flushPending = async (): Promise<void> => {
86 if (closed || isProcessing) return;
87 if (pendingFiles.size === 0) return;
88
89 isProcessing = true;
90 const batch = Array.from(pendingFiles).slice(0, maxFilesPerTick);
91 for (const file of batch) pendingFiles.delete(file);
92
93 try {
94 const [fileEmbeds, identifierEmbeds] = await Promise.all([
95 refreshFileSearchEmbeddings({ rootDir: options.rootDir, relativePaths: batch }),
96 refreshIdentifierEmbeddings({ rootDir: options.rootDir, relativePaths: batch }),
97 ]);
98 if (fileEmbeds > 0 || identifierEmbeds > 0) {
99 console.error(
100 `Embedding tracker refreshed ${batch.length} file(s) | file-vectors=${fileEmbeds}, identifier-vectors=${identifierEmbeds}`,
101 );
102 }
103 } catch (error) {
104 console.error("Embedding tracker refresh failed:", error);
105 } finally {
106 isProcessing = false;
107 if (pendingFiles.size > 0) schedule(100);
108 }
109 };
110
111 try {
112 watcher = watch(options.rootDir, { recursive: true }, (_eventType, fileName) => {

Callers 1

scheduleFunction · 0.85

Calls 3

scheduleFunction · 0.70

Tested by

no test coverage detected