Skip to content

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 21, 2026

Description

This PR addresses an issue where file IDs were changing upon re-indexing, breaking data integrity. The issue was caused by the use of INSERT OR REPLACE, which deletes the existing row and creates a new one with a new auto-incremented ID.

Changes

  • Replaced INSERT OR REPLACE with INSERT ... ON CONFLICT(path) DO UPDATE SET ... (UPSERT) in insert_file().
  • This ensures that if a file with the same path already exists, its ID is preserved while updating its hash and indexed timestamp.
  • Explicitly fetching the ID after upsert to ensure correctness across SQLite versions/drivers.

Validation

  • Verified with a reproduction test case that file IDs remain constant after re-inserting the same file with a different hash.
  • Ran existing tests to ensure no regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants