Commit 47f78fd
authored
Fixes a notes data-loss bug where purgeAllSteps(fileID) ignored its fileID (#4712)
## Summary
This fixes a notes data-loss bug where purgeAllSteps(fileID) ignored its
fileID argument and deleted step documents for all notes in
io.cozy.notes.steps, not only the targeted note.
## Bug story
We investigated a production incident where a user lost note content
after a reload.
- On Tuesday, the note 019d1f37-b201-7d8a-901d-39922cf7c647 accumulated
a large number of unsaved note steps.
- On Wednesday, Couch/stack logs showed a BulkDeleteDocs for
io.cozy.notes.steps batch containing step IDs from multiple different
notes.
- In the stack code, purgeAllSteps(inst, fileID) was supposed to clear
steps for one note after a schema update or .cozy-note overwrite/import.
- But the implementation iterated the whole io.cozy.notes.steps database
and deleted every step doc it found, regardless of fileID.
This means that an action on note B could wipe unsaved steps for note A.
The most likely production trigger is: overwrite/import of another
existing .cozy-note file3 files changed
+81
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
| 259 | + | |
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
263 | 268 | | |
264 | 269 | | |
265 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
446 | | - | |
447 | | - | |
| 448 | + | |
| 449 | + | |
448 | 450 | | |
449 | 451 | | |
450 | 452 | | |
451 | 453 | | |
452 | 454 | | |
453 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
454 | 466 | | |
455 | | - | |
456 | 467 | | |
457 | 468 | | |
458 | 469 | | |
| |||
472 | 483 | | |
473 | 484 | | |
474 | 485 | | |
475 | | - | |
| 486 | + | |
476 | 487 | | |
477 | 488 | | |
478 | 489 | | |
479 | 490 | | |
480 | 491 | | |
481 | | - | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
482 | 505 | | |
483 | 506 | | |
484 | 507 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
503 | 550 | | |
504 | 551 | | |
505 | 552 | | |
| |||
0 commit comments