Commit 8d2b6a1
committed
lakebox: skip state file writes when nothing changed
setDefault and clearDefault unconditionally rewrote ~/.databricks/
lakebox.json even when the in-memory state was identical to what was
already on disk: clearing a profile that wasn't in the map, or
re-setting the same value. That created or touched the file for
no-op operations.
Add change-detection guards to both: setDefault is a no-op when the
profile already maps to the requested ID; clearDefault is a no-op
when the profile isn't in the map. Result: a CLI invocation that
doesn't change state can no longer cause a file to spring into
existence on a fresh machine.
Tests:
- clearDefault on a missing profile must leave the file absent
- setDefault with an unchanged value must not bump the mtime
- getDefault on a fresh state must not create the file (regression
test for the read-only path)
Co-authored-by: Isaac1 parent 59f8216 commit 8d2b6a1
2 files changed
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
76 | 103 | | |
77 | 104 | | |
78 | 105 | | |
| |||
0 commit comments