docir — design documents Graph

Documents / Issues / issue-43be097cae13

Archive, tag rename and forced delete wrote the index's copy over an unindexed hand edit

Mechanical rewrites built the file from the index row, so a hand edit nothing had re-indexed was silently overwritten.

issue-43be097cae13issueresolved#integrity
View as Markdown◉ View in graph

What is wrong

archive, unarchive, tag rename, tag rm --force and the edge strip of delete --force each rewrite a document's file, and they built that rewrite from the index row instead of the file. A body edited by hand and not yet re-indexed (any store with no daemon watching docs/: CI, --no-daemon, a daemon not yet started) was written over with the copy the index remembered, and the command exited 0.

How it showed

Found while fixing issue-5e61f46f19f8: those commands wrote document.with_updates(...) where document came from uow.documents.get. update already started from the file.

The fix

Each of them now reads the file and applies its change to that. The mechanical rewrites carry an acknowledgement only from the version they actually rewrote, so a caller who read the document before the hand edit is still refused a later --replace-body. Pinned by tests/modules/documents/test_mechanical_rewrites_keep_hand_edits.py.

To amend: Re-verify: