Commit 1c9f2a4
committed
fix: surface real DB errors in delete_rule_inner instead of swallowing them
Addresses review nit on #200. The previous
`.ok().and_then(|s| s.query_row(..).ok())` pattern silently conflated
three cases:
1. row exists → Some(rule) ✓
2. row absent (QueryReturnedNoRows) → None ✓
3. real DB error (lock contention, corruption, IO) → None ✗
→ DB delete proceeds, disk file leaks
Switch to an explicit match on rusqlite::Error so only
QueryReturnedNoRows maps to None; every other error is returned before
the DELETE runs. Same treatment for rule_writer::delete_rule_file — its
existing file-exists guard already handles the legitimate "disk file
already gone" case, so any error it raises now is a real IO/permission
failure worth surfacing.
Adds test_delete_rule_missing_id_is_not_an_error to pin the
QueryReturnedNoRows arm. 2015/2015 lib tests pass.1 parent 310524d commit 1c9f2a4
1 file changed
Lines changed: 30 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
| 142 | + | |
| 143 | + | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
145 | 151 | | |
146 | 152 | | |
147 | | - | |
| 153 | + | |
148 | 154 | | |
149 | | - | |
150 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
151 | 161 | | |
152 | 162 | | |
153 | 163 | | |
154 | 164 | | |
155 | 165 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
159 | 169 | | |
160 | 170 | | |
161 | 171 | | |
| |||
611 | 621 | | |
612 | 622 | | |
613 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
614 | 636 | | |
615 | 637 | | |
616 | 638 | | |
| |||
0 commit comments