Repository navigation
Cloud download restores documents deleted locally (NDI-matlab#1238) - #371
Merged
Merged
Conversation
Port of VH-Lab/NDI-matlab#1241. DID retires the id of a document removed from the database and refuses to add it again, so a cloud sync failed to ingest a downloaded document that had been deleted locally. - restore_deleted_id (keyword-only, default False) on ndi_database.add / add_many, ndi_session.database_add and ndi_dataset.database_add; the SQLite driver maps it to DID-python's OnDeletedId="restore", passed only when set. - The cloud sync's ingestion (_ingest_downloaded_docs, used by download-new, mirror-from-remote and two-way sync) and orchestration._sync_download_new pass restore_deleted_id=True. - Bridge contracts for database_add (session, dataset) and ndi.database/add gain the RestoreDeletedId argument. - tests/test_restore_deleted_document.py, mirroring the MATLAB tests. Requires VH-Lab/DID-python with add_docs OnDeletedId (DID-python#110, merged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011v7R5vMg5Qz8W7zUb26wM2
The bridge-completeness job checks NDI-matlab out at this PR's matching branch, where downloadNdiDocuments.m, dataset.m, session.m (4930b5dd) and database.m (b5e629c0) carry the RestoreDeletedId change this PR ports. Each entry's python_path is changed in this PR, so this is a regular port and the hash is the record of examination. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011v7R5vMg5Qz8W7zUb26wM2
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.
Port of VH-Lab/NDI-matlab#1241 (fixes VH-Lab/NDI-matlab#1238 on the Python side).
Summary
DID retires the id of a document removed from the database and refuses to add it again. So a cloud sync couldn't ingest a downloaded document that the user had deleted locally and the remote still holds.
restore_deleted_id=Falseonndi_database.add/add_many,ndi_session.database_addandndi_dataset.database_add. It's MATLAB's'RestoreDeletedId', snake-cased likeerror_if_not_found.SQLiteDrivermaps it to DID-python'sadd_docs(..., OnDeletedId="restore")and passes it only when it's set, as NDI-matlab'sdidsqlite/do_adddoes. The default call is unchanged.restore_deleted_id=Truewhere it ingests downloads, because a cloud document is the same document coming back:cloud.sync.operations._ingest_downloaded_docs, used by download-new, mirror-from-remote and two-way sync. This matches the end of MATLAB'sdownloadNdiDocuments.cloud.orchestration._sync_download_new.tests/conftest.py:FakeDataset.database_addaccepts the new keyword, as the real one does.INTERFACE UPDATE: I have modified the bridge contract for
database_add(session, dataset) andndi.database/addto reflect the MATLAB source (newRestoreDeletedIdargument).Requires DID-python's
OnDeletedIdoption (VH-Lab/DID-python#110, already merged).Tests
tests/test_restore_deleted_document.py, mirroring the MATLAB tests:restore_deleted_id=Truerestores it_ingest_downloaded_docsbrings back a document deleted locallyblack --checkandruff checkare clean.ndr,vhlab-*,ndi-compress, ...) that the sandbox couldn't download.Generated by Claude Code