Repository navigation
Sync sqlitedb and database to DID-matlab#227: delete originals after commit, don't reopen a vanished database - #97
Merged
Conversation
… database Syncs the two parts of DID-matlab#227 that DID-python didn't have yet. The transactions, replay and pre-commit replaced-file check it adds match #93 and #94 here. - delete_original sources are queued and deleted once the write operation commits (_delete_after_commit, flushed by _journal_committed), not during ingest. A rollback no longer leaves the only copy of a file unreferenced in FileDir. A source two files share is deleted once, and a missing one isn't a warning, matching MATLAB. - _recover_transaction doesn't reopen a database file that no longer exists, because reopening created a new, empty database there. It raises the original error with FileNotFoundError as its cause (MATLAB: DID:SQLITEDB:DatabaseFileGone). test_open_doc_locations' MATLAB-shaped fixture relied on the old order. Its two files share one original, and the first file's delete_original removed the source before the second was copied. Both are now ingested, so the no-copy-no-original test removes filename2's copy itself. Bridge notes added for sqlitedb and database. DID-matlab's journal_mode change has nothing to port, since Python never changes journal_mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Dn4gCNCU2jUGdmfPVCAGK
Both files were last touched by bb39399, the commit DID-matlab#227 merged with. The diff is ported in the previous commit, apart from the journal_mode change, which has nothing to port. This clears the "Bridge coverage vs DID-matlab" drift that #227 introduced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Dn4gCNCU2jUGdmfPVCAGK
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.
Syncs DID-python to VH-Lab/DID-matlab#227 (
bb39399). That merge makes "Bridge coverage vs DID-matlab" report drift onsqlitedb.manddatabase.mfor every DID-python PR, and this clears it: the check reports 0 problems again.Most of #227 (one transaction per write operation, replay after reopen, and the pre-commit replaced-file check) mirrors what is already here from #93 and #94. Two parts weren't, and are ported here.
Changes
delete_originalsources are deleted only after the write operation commits._delete_after_commitqueues them and_journal_committeddeletes them, instead of deleting during ingest, so a rollback no longer leaves the only copy of a file unreferenced in FileDir. Reclaimed cached copies already waited for the commit. A source that two files share is deleted once, and one that's already gone isn't a warning, matching MATLAB's suppression ofMATLAB:DELETE:FileNotFound._recover_transactiondoesn't reopen a database file that no longer exists. Reopening created a new, empty database at the path. It now raises the original error withFileNotFoundErroras its cause, matching MATLAB'sDID:SQLITEDB:DatabaseFileGone.sqlitedbanddatabaseare bumped tobb39399, the last commit touching each file, with notes added.database.m's change (journal_mode=MEMORYinstead ofOFFforValidate=false) has nothing to port, since Python never changesjournal_mode.BEGIN IMMEDIATEversus a deferredBEGIN,changes()versusrowcount, and where the fields cache is restored. Each has the same effect.Test changes
test_open_doc_locations' MATLAB-shaped fixture relied on the old order. Its two files share one original, and the first file'sdelete_originalremoved it before the second was copied. Both are now ingested, sotest_a_file_with_no_ingested_copy_and_no_original_is_an_errorremoves filename2's ingested copy itself.Locally:
black --check,ruff check(0.16.5),pytest(802 passed) andcheck_bridge_coverage.pyagainst DID-matlabmain(f4a4905), which reports 0 problems.Generated by Claude Code