Commit ed39e3a
committed
Fixed: Play reported
* Fix: Prevent a rare `SQLiteConstraintException` that occurred when the `saveHistory()` method was called at the same time by the migration job (running on the IO thread) and the main application flow. There is very little chance of this race condition, which is why it caused only a single crash.
* Wrapped the `saveHistory()` method inside a coroutine `Mutex` to make concurrent database writes thread-safe, ensuring that only one insertion executes at a time while others wait. This prevents data loss during migration and ensures that new history entries are safely persisted in the database.android.database.sqlite.SQLiteConstraintException while saving history.1 parent 46c97a3 commit ed39e3a
File tree
1 file changed
+25
-19
lines changed- core/src/main/java/org/kiwix/kiwixmobile/core/dao
1 file changed
+25
-19
lines changedLines changed: 25 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
86 | 93 | | |
87 | | - | |
88 | 94 | | |
89 | 95 | | |
90 | 96 | | |
| |||
0 commit comments