Repository navigation
fix(import): the later backup decides a message's mark and text, unsent part included (#1741, #1804) - #1983
Conversation
The #1924 tests ran the #1804 scenario without its unsent part: backup B carried no mark. The new test gives B the Unsent mark its unsent part brings, and checks every order, one import of both files in either order included: with B the later backup the message holds B's text, versions and mark and search finds neither copy's text; with the dates swapped it holds A's with no mark and search finds A's text; with no dates the version times pick A's text and B's mark adds, as #1801 left them. Part of #1741, #1804. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two Fixes entries for the 0.11.0 Importing list: a mark is cleared by a newer backup that no longer has it, and the second file of one import no longer loses its mark (#1741); a newer backup that unsent a part gives the message its text whatever the edit times say (#1804). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Findings of the review of 42be2b2 with no line in the diff. Each is answered by a later marked comment quoting it.
|
The fix landed with #1966, whose Features entry already describes it. Drop the two Fixes bullets that repeated it under a later date. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Fold the unsent-part test into the_later_backup_decides_the_text_whatever_the_version_times_say: backup B now carries the Unsent mark, and the test checks search and the undated files there. It also counts earlier versions in message_versions_fts, which keeps them for an Unsent message, so a stale version of backup A or a missing one of backup B fails the test. every_order returns each order's name and database with what it holds, so no test copies its order names or database path. text_hits sits with the other helpers and replaces the inline count in the searchable test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…her order When one import held a dated file and an undated one, the staged message kept the date only when the dated file was read first. Read second, the dates could not decide, nothing set the date, and a later import fell back to adding marks: a backup made later without the mark left the message Unsent. The staged message now takes the dated copy's date when it has none. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Its doc comment still called it the one rule for which copy is the later backup, which later_backup_sql now is. Also part later_backup_sql's two paragraphs, which ran together. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e in either order" This reverts commit 6c96678. Giving the staged row the dated copy's date whenever an undated copy also contributed makes the dated copy's date decide for the undated copy too at promotion, which drops a mark or an edit the undated copy brought when the stored message came from a later backup. Neither rule stores what two separate imports store in every order, so the order-dependence of a mixed import is filed as its own issue rather than fixed here. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mbeisser1
left a comment
There was a problem hiding this comment.
Re-review of the fix commits (Standards 3, Correctness 1), posted after the push at d92d4b2. Each is answered in its thread.
All four findings are about commit 6c96678, which 6562383 reverts, so their lines are no longer in the diff and each is listed and answered here.
-
Standards · rule (
docs/architecture/, the backup date rule). The architecture doc's "backup_taken_at keeps the date of the backup that decided the stored copy" no longer matched 6c96678: a mixed import stored the dated copy's date beside the undated copy's mark.
Answered by the revert 6562383: the attempted fix is withdrawn and the order-dependence is Deferred to #1989. -
Standards · judgement (
crates/server/server/src/imports_api/staging.rs). 6c96678 pushed a doc comment line to about 115 characters.
Answered by the revert 6562383: the attempted fix is withdrawn and the order-dependence is Deferred to #1989. -
Standards · judgement (
crates/server/server/src/imports_api/tests/backup_dates.rs). The test 6c96678 added copied the order names instead of usingevery_order, and left out the two "apart" orders.
Answered by the revert 6562383: the attempted fix is withdrawn and the order-dependence is Deferred to #1989. -
Correctness · bug (
crates/server/server/src/db/staging.rs, with 6c96678). With a stored message from a LATER backup, one import of an undated Unsent copy plus an EARLIER dated copy got the date EARLIER, and the Unsent mark was dropped at promotion, where two separate imports of the same files keep the message Unsent.
Answered by the revert 6562383: the attempted fix is withdrawn and the order-dependence is Deferred to #1989.
|
Answers to the findings in #1983 (comment).
Fixed in 28350fd: the two tests are now one.
Fixed in 75218e2: the doc comment on
Deferred: #1989. A fix was tried (6c96678) and reverted in 6562383: giving the staged row the dated copy's date lets that date decide for the undated copy's mark and text at promotion, which drops a mark separate imports keep. The issue records both scenarios. |
|
Review summary for 42be2b2, pushed as d92d4b2 (the PR with main merged in twice, conflict-free).
Every acceptance box of #1741 and #1804 was verified against the tests from #1966 plus the one merged here. No commit was needed for CI and no user thread is open. CI run 37727199790 on d92d4b2: success. |
Bug Description
Expected: Between two copies of one message from one source, the copy from the later backup decides the message's mark (Deleted in the source app or Unsent, mark or no mark) and its text, parts, earlier versions and unsent marks, across imports and within one import, in any file order. A file without a backup date keeps the rules for files without one: a mark adds and is never cleared, and the copy whose newest earlier version is newer gives the text.
Actual (before #1924): A mark was only ever added, never cleared, and within one import the first file staged decided the mark, because
staging_messagesis unique on(account_id, source, guid)and the insert isON CONFLICT DO NOTHING(#1741). An append took a later edit only when its newest earlier version was newer, so a later backup whose only change was an unsent part, or one edit after an unsend, kept the older text (#1804).Root Cause
The conversation file did not say when its backup was made, so the import could not tell which copy was newer and used rules of thumb: marks add, and version times compare.
Fix Description
#1924 (commit 7a8435e, PR #1966) already built both decisions. It added
export.backup_taken_at_unix_msto the conversation file,staging_messages.backup_taken_atandmessages.backup_taken_at, and the one rulelater_backup_sql/later_backupincrates/server/server/src/db/staging.rs.promote_deletion_markslets the later backup set or clear the mark across imports;write_edit_maptakes the later backup's text and versions whatever their times say, and keepslater_edit_sqlonly as the fallback for undated (or equally dated) copies;add_staged_copyinimports_api/staging.rshandles the second copy thatON CONFLICT DO NOTHINGskips, so the second file of one import gives its mark and text.docs/architecture/contacts-identities-and-messages.md, the common-message page and the user import page say the rule and that a file without a date keeps marks additive. Its tests inimports_api/tests/backup_dates.rscover the #1741 criteria in every order (together, together reversed, apart, apart reversed), the swapped dates, the undated fallback, and the #1804 text case.What was left, and what this PR adds:
the_later_backup_decides_an_unsent_part_whatever_the_version_times_say, gives B the Unsent mark its unsent part brings and checks all four orders, both orders of a single two-file import included: B later gives B's text, part 0 version and Unsent mark, and search finds neither copy's text; dates swapped gives A's text and part 1 versions with no mark, and search finds A's text; no dates gives A's text by the version times, as fix(server): an append from a later backup takes a stored message's later edit #1801 left them, with B's mark added.No code change was needed.
How to Reproduce (Before Fix)
later_backup_sqlandlater_backup).cargo test -p message-crate-server --lib backup_dates::the_later_backup_decides_an_unsent_part.How to Verify (After Fix)
cargo test -p message-crate-server --lib backup_dates(10 tests pass).AND 0inlater_backup_sql,&& falsein bothlater_backuparms), the new test fails withtogether: left: Held { text: "zqharbor zqyonder", … } right: Held { text: "zqbeacon", … }. Checked locally, then reverted../scripts/check-pr.shandcargo test -p message-crate-serverpass.Impact Assessment
Regression Risk
None in behaviour: this PR adds one test and two CHANGELOG entries.
Checklist
Related Issues
Closes #1741
Closes #1804
Built on #1924 (PR #1966).
🤖 Generated with Claude Code