MCPcopy
hub / github.com/mixedbread-ai/mgrep / handleFileEvent

Function handleFileEvent

src/commands/watch.ts:203–248  ·  view source on GitHub ↗
(
      eventType: fs.WatchEventType,
      dirPath: string,
      name: string,
    )

Source from the content-addressed store, hash-verified

201 }
202
203 function handleFileEvent(
204 eventType: fs.WatchEventType,
205 dirPath: string,
206 name: string,
207 ): void {
208 const filePath = path.join(dirPath, name);
209
210 if (fileSystem.isIgnored(filePath, watchRoot)) {
211 return;
212 }
213
214 const stats = getPathStats(filePath);
215 if (stats === undefined) {
216 return;
217 }
218
219 if (stats === null) {
220 handleDeletion(filePath);
221 return;
222 }
223
224 if (stats.isDirectory()) {
225 watchDirectory(filePath);
226 return;
227 }
228
229 if (!stats.isFile()) {
230 return;
231 }
232
233 void uploadFile(
234 store,
235 options.store,
236 filePath,
237 path.basename(filePath),
238 config,
239 )
240 .then((didUpload) => {
241 if (didUpload) {
242 console.log(`${eventType}: ${filePath}`);
243 }
244 })
245 .catch((error) => {
246 console.error("Failed to upload changed file:", filePath, error);
247 });
248 }
249
250 function watchDirectory(dirPath: string): void {
251 if (watchers.has(dirPath)) {

Callers 1

watchDirectoryFunction · 0.85

Calls 5

getPathStatsFunction · 0.85
handleDeletionFunction · 0.85
watchDirectoryFunction · 0.85
uploadFileFunction · 0.85
isIgnoredMethod · 0.65

Tested by

no test coverage detected