Commit 155ac00
committed
fix(key-backup): count only the sessions actually written
The import counted every session it decrypted. The database insert is an
on_conflict_ignore, so a session already in the store was reported as
imported while nothing was written - the run that produced this fix
printed "Imported: 18275" for 18272 new rows.
That is a milder version of the defect this code path was written to
replace, which counted sessions it discarded. A number that overstates
what happened is what let the original bug hide.
Sessions now go through client.olm.inbound_group_store.add() first, the
way nio does when it imports a key itself: it returns False for a session
already held, and only then is the database write skipped. Sessions loaded
from the store at startup are in that in-memory set, so a re-import
reports honestly instead of claiming the whole backup again.
Reported separately as "Already in the store", and a run where everything
was already present no longer exits non-zero.
Found while reviewing #77 after merge.
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>1 parent cdd085a commit 155ac00
1 file changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| 463 | + | |
463 | 464 | | |
464 | 465 | | |
465 | 466 | | |
| |||
485 | 486 | | |
486 | 487 | | |
487 | 488 | | |
488 | | - | |
489 | 489 | | |
490 | | - | |
491 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
492 | 505 | | |
493 | 506 | | |
494 | 507 | | |
| |||
498 | 511 | | |
499 | 512 | | |
500 | 513 | | |
| 514 | + | |
| 515 | + | |
501 | 516 | | |
502 | | - | |
| 517 | + | |
503 | 518 | | |
504 | 519 | | |
505 | 520 | | |
| |||
0 commit comments