Commit 750bde8
authored
Fix bug where simultaneous edits could lose data (#1313)
The cause of the issue was normalization: U+0061 LATIN SMALL LETTER A
followed by U+0301 COMBINING ACUTE ACCENT was in the Mongo database (for
example), but what got saved into Mongo was U+00E1 LATIN SMALL LETTER A
WITH ACUTE. The diff algorithm naturally compared those two as different
(since it's doing a basic byte comparison on strings), and therefore a
delta update was being submitted which changed á to á. Mongo was
therefore writing that field's value in the database, accidentally
overwriting any previous edits to that field from a different user.
The answer is to normalize the pristineEntry value (the value that came
out of the database) before passing it to the diffing algorithm, so that
it's comparing NFC to NFC. With this change, I can no longer reproduce
the test case for #1248, which I was consistently reproducing before the
change. So although there might be other situations that can also cause
edits to be lost, I'm confident that the most mysterious one is fixed.1 parent cacc253 commit 750bde8
File tree
1 file changed
+1
-1
lines changed- src/angular-app/languageforge/lexicon/editor
1 file changed
+1
-1
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| |||
0 commit comments