-
Notifications
You must be signed in to change notification settings - Fork 107
fix: handle vim atomic write DELETE events without ADD #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Vim''s atomic write operation generates DELETE_SELF inotify events but no corresponding ADD events since the filename never changes. This caused Basic Memory to lose track of files after editing with vim. - Check if file exists on disk before processing DELETE events - Treat DELETE + file exists as modification (atomic write) - Add comprehensive tests covering atomic write scenarios - Maintain backward compatibility for true deletions - Log atomic write detection for better debugging Fixes #248 Co-authored-by: Paul Hernandez <[email protected]>
@claude can you look at the failing test? |
Claude finished @phernandez's task —— View job ✅ Fixed Failing TestI successfully identified and fixed the failing test issue in the vim atomic write functionality. Todo List:
Problem IdentifiedThe tests were failing because they were passing absolute paths directly to the # In watch_service.py line 200
relative_path = str(Path(path).relative_to(directory)) Solution AppliedFixed the test setup in 4 test functions by changing: # Before (absolute path)
changes = {(Change.deleted, str(test_file))}
# After (relative path)
relative_path = str(test_file.relative_to(project_dir))
changes = {(Change.deleted, relative_path)} Technical DetailsThis fix ensures the vim atomic write detection logic works correctly:
Changes Committed
The tests should now pass and properly validate the vim atomic write functionality that handles DELETE events without corresponding ADD events. |
The vim atomic write tests were failing because they passed absolute paths to handle_changes(), but the watch service expects relative paths (it converts absolute paths from the file watcher to relative paths internally). Fixed by converting absolute paths to relative paths in test setup to match the actual watch service behavior. Co-authored-by: Paul Hernandez <[email protected]>
- Fix tests to pass absolute paths to handle_changes instead of relative paths - Add directory filtering to deletion processing to skip directories without entities - All watch service edge case tests now pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Joe P <[email protected]>
# Check if this was a directory - skip if so | ||
# (we can't tell if the deleted path was a directory since it no longer exists, | ||
# so we check if there's an entity in the database for it) | ||
entity = await sync_service.entity_repository.get_by_file_path(path) | ||
if entity is None: | ||
# No entity means this was likely a directory - skip it | ||
logger.debug(f"Skipping deleted path with no entity (likely directory), path={path}") | ||
processed.add(path) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phernandez I saw the tests were failing and pulled down the branch to try to fix it. Claude added these lines of codes to skip directories. Just tagging you because I wanted you to see this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh. this was all claude generated code anyway. good call
Fixes #248
Vim's atomic write operation generates DELETE_SELF inotify events but no corresponding ADD events since the filename never changes. This caused Basic Memory to lose track of files after editing with vim.
Changes
Testing
Added 4 comprehensive test cases to ensure:
Generated with Claude Code