fix: prevent event storm when gitRefsPath is empty (#883)
When gitRefsPath is empty (not in a git repo), strings.HasPrefix(path, "") always returns true, causing every file write in .beads/ directory (including daemon.log) to trigger debouncer and create an event storm. This fix adds a check to ensure gitRefsPath is not empty before the HasPrefix comparison. Fixes the issue where daemon.log grows rapidly (17MB+) due to the self-triggering loop: write log -> detect change -> write log -> ... Co-authored-by: Test User <test@example.com>
This commit is contained in:
@@ -210,7 +210,8 @@ func (fw *FileWatcher) Start(ctx context.Context, log daemonLogger) {
|
||||
}
|
||||
|
||||
// Handle git ref changes (only events under gitRefsPath)
|
||||
if event.Op&fsnotify.Write != 0 && strings.HasPrefix(event.Name, fw.gitRefsPath) {
|
||||
// Fix: check gitRefsPath is not empty, otherwise HasPrefix("any", "") is always true
|
||||
if fw.gitRefsPath != "" && event.Op&fsnotify.Write != 0 && strings.HasPrefix(event.Name, fw.gitRefsPath) {
|
||||
if fw.shouldLogGitRefChange() {
|
||||
log.log("Git ref change detected: %s", event.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user