Commit 6471b3f
authored
fix(state-watch): watch canonical ini files atomically (#1953)
## Summary
- switch the state watcher back to watching canonical `*.ini` files
directly instead of using directory-level `.ini.new` normalization
- configure an explicit atomic replacement window for state file
watchers so `.ini.new -> .ini` replacements collapse into canonical file
change handling
- keep the existing polling behavior for `disks.ini` and `shares.ini`,
and update the state watcher tests to cover the canonical-file watcher
shape
## Testing
- `pnpm --filter ./api test
src/__test__/store/watch/state-watch.test.ts`
- `pnpm --filter ./api test
src/__test__/store/watch/state-watch.integration.test.ts`
- deployed `api` to `devgen` via `pnpm --filter ./api unraid:deploy
devgen`
- verified on `devgen` that an atomic `var.ini.new -> var.ini`
replacement emitted `Loading state file for var after change` in
`/var/log/graphql-api.log`
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Tests**
* Enhanced state file watching tests to verify per-file monitoring with
atomic replacement detection and conditional polling behavior.
* **Refactor**
* Improved state file watching mechanism for more reliable detection of
file changes and atomic file replacements across critical system state
files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 7265105 commit 6471b3f
File tree
3 files changed
+47
-117
lines changed- api/src
- __test__/store/watch
- store/watch
3 files changed
+47
-117
lines changedLines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | | - | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
94 | 103 | | |
| 104 | + | |
95 | 105 | | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
100 | 110 | | |
101 | | - | |
102 | | - | |
| 111 | + | |
| 112 | + | |
103 | 113 | | |
| 114 | + | |
104 | 115 | | |
105 | 116 | | |
106 | 117 | | |
| |||
127 | 138 | | |
128 | 139 | | |
129 | 140 | | |
130 | | - | |
| 141 | + | |
131 | 142 | | |
132 | 143 | | |
133 | 144 | | |
| |||
136 | 147 | | |
137 | 148 | | |
138 | 149 | | |
139 | | - | |
| 150 | + | |
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| |||
146 | 157 | | |
147 | 158 | | |
148 | 159 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 160 | | |
173 | 161 | | |
174 | 162 | | |
| |||
178 | 166 | | |
179 | 167 | | |
180 | 168 | | |
181 | | - | |
182 | | - | |
| 169 | + | |
| 170 | + | |
183 | 171 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 172 | + | |
| 173 | + | |
207 | 174 | | |
208 | | - | |
| 175 | + | |
209 | 176 | | |
210 | 177 | | |
211 | 178 | | |
212 | 179 | | |
213 | 180 | | |
214 | | - | |
| 181 | + | |
215 | 182 | | |
216 | 183 | | |
217 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 17 | + | |
| 18 | + | |
43 | 19 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
54 | 28 | | |
55 | 29 | | |
56 | 30 | | |
| |||
80 | 54 | | |
81 | 55 | | |
82 | 56 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 57 | + | |
| 58 | + | |
89 | 59 | | |
90 | 60 | | |
91 | 61 | | |
| |||
124 | 94 | | |
125 | 95 | | |
126 | 96 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 97 | + | |
134 | 98 | | |
135 | 99 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 100 | + | |
141 | 101 | | |
142 | 102 | | |
143 | 103 | | |
| |||
0 commit comments