Fix: Race conditions in move operations and improve installation#9
Merged
raythurman2386 merged 2 commits intomainfrom Feb 28, 2026
Merged
Fix: Race conditions in move operations and improve installation#9raythurman2386 merged 2 commits intomainfrom
raythurman2386 merged 2 commits intomainfrom
Conversation
Root cause: fsnotify fires multiple events for the same file (e.g., Create then Write when a download completes, or the move triggering a Rename event). The daemon was processing each event, causing duplicate move attempts. Changes: - Add 100ms event debouncing in watcher to coalesce rapid events for the same file path into a single event (internal/watcher/watcher.go) - Add graceful handling in move: if source is already gone but exists at destination, treat as success (internal/actions/actions.go) - Handle TOCTOU race: re-check source existence after a failed rename to catch files moved between stat and rename (internal/actions/actions.go) - Add tests for move with already-moved source (internal/actions/actions_test.go) This prevents false 'Action failed' error logs when files are moved successfully but multiple fsnotify events fire for the same file.
Move operation fixes: - Handle TOCTOU races: source disappearance at any point now returns success - Simplify move() logic with renameOrSkip() helper - Remove fragile stat checks that were themselves racy Installation improvements: - Makefile now stops running strawd before installing binaries - install.sh (curl install): Stop existing instances before binary replacement - install.sh: Properly handle fresh install vs upgrade with conditional start/restart - install_service.sh: Stop service before updating, conditional start/restart This ensures: 1. No false 'Action failed' errors when files are moved by duplicate events 2. Clean binary replacement without running multiple daemon instances 3. Proper service management on both fresh installs and upgrades
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes race conditions in file move operations and improves installation to prevent multiple daemon instances.