Skip to content

Commit 70fdd47

Browse files
committed
Ignore chmod-only watch events
1 parent 4b260e1 commit 70fdd47

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎command_mcp.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,16 +472,20 @@ Setup: Add to your AI client's MCP config:
472472
if shouldSkipEvent(absRoot, event, ignored, outputPath, cachePath, absConfigPath) {
473473
continue
474474
}
475+
op := event.Op &^ fsnotify.Chmod
476+
if op == 0 {
477+
continue
478+
}
475479
relName := event.Name
476480
if rel, relErr := filepath.Rel(absRoot, event.Name); relErr == nil {
477481
relName = rel
478482
}
479-
addPending(relName, event.Op)
483+
addPending(relName, op)
480484
if flags.Verbose {
481-
LogInfof("Event: %s %s", event.Op, event.Name)
485+
LogInfof("Event: %s %s", op, event.Name)
482486
}
483487

484-
if event.Op&(fsnotify.Create|fsnotify.Rename) != 0 {
488+
if op&(fsnotify.Create|fsnotify.Rename) != 0 {
485489
if err := syncWatchDirectories(watcher, absRoot, ignored, watchedDirs); err != nil {
486490
LogErrorf("Sync watch dirs failed: %v", err)
487491
}

‎command_watch.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,20 @@ Examples:
349349
if shouldSkipEvent(absRoot, event, ignored, outputPath, cachePath, absConfigPath) {
350350
continue
351351
}
352+
op := event.Op &^ fsnotify.Chmod
353+
if op == 0 {
354+
continue
355+
}
352356
relName := event.Name
353357
if rel, relErr := filepath.Rel(absRoot, event.Name); relErr == nil {
354358
relName = rel
355359
}
356-
addPending(relName, event.Op)
360+
addPending(relName, op)
357361
if flags.Verbose {
358-
LogInfof("Event: %s %s", event.Op, event.Name)
362+
LogInfof("Event: %s %s", op, event.Name)
359363
}
360364

361-
if event.Op&(fsnotify.Create|fsnotify.Rename) != 0 {
365+
if op&(fsnotify.Create|fsnotify.Rename) != 0 {
362366
if err := syncWatchDirectories(watcher, absRoot, ignored, watchedDirs); err != nil {
363367
LogErrorf("Sync watch dirs failed: %v", err)
364368
}

‎index_manager.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func (m *IndexManager) ApplyChanges(ctx context.Context, changes map[string]fsno
381381
}
382382
}
383383

384-
if op&(fsnotify.Create|fsnotify.Write|fsnotify.Chmod) == 0 {
384+
if op&(fsnotify.Create|fsnotify.Write) == 0 {
385385
continue
386386
}
387387

@@ -396,14 +396,14 @@ func (m *IndexManager) ApplyChanges(ctx context.Context, changes map[string]fsno
396396
if matcher.shouldIgnore(relPath, baseName, isDir) {
397397
if removeNodeByRelPath(m.index.Tree, relPath) {
398398
result.Changed = true
399-
result.ChangedPaths[relPath] |= op & (fsnotify.Create | fsnotify.Write | fsnotify.Chmod)
399+
result.ChangedPaths[relPath] |= op & (fsnotify.Create | fsnotify.Write)
400400
}
401401
continue
402402
}
403403

404404
if upsertNodeByRelPath(m.index.Tree, m.rootPath, relPath, isDir, mtime, m.cache, m.synonymsMax) {
405405
result.Changed = true
406-
result.ChangedPaths[relPath] |= op & (fsnotify.Create | fsnotify.Write | fsnotify.Chmod)
406+
result.ChangedPaths[relPath] |= op & (fsnotify.Create | fsnotify.Write)
407407
}
408408
}
409409

0 commit comments

Comments
 (0)