fix(cli.update): deduplicate on file_id instead of sha#138
Merged
Conversation
When re-adding a query after removal, files may have different checksums (SHA) but the same file_id. The previous code checked by SHA, causing it to try adding existing files as new ones, resulting in DB constraint violations on the unique file_id constraint. Now we check by file_id instead: - Fetch existing file_ids from DB before processing - For each fetched file, check if its file_id exists in DB - If yes, fetch the existing file object from DB - If no, it's a new file that needs to be added Changes: - esgpull/cli/update.py: Check by file_id instead of SHA - esgpull/models/sql.py: Add all_file_ids() method - tests/conftest.py: Add db fixture - tests/test_context.py: Add test for file_id checking This keeps database logic in update.py (not Context) and properly handles the remove-and-re-add query scenario.
Closed
AtefBN
approved these changes
Feb 5, 2026
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.
Follow-up to #132 that handles the missing case: