Commit 4677199
authored
fix(openscience): atomic + locked session writes, distinguish logout from read error (#131)
- saveSession uses atomic temp+rename so a crash or concurrent reader never
sees a torn session file.
- updateSession serializes its read-modify-write under a lock, so two
concurrent patches (interactive last_check_ts vs background cached_v) can't
lose each other's field.
- getSession distinguishes a MISSING file (genuine logout → null) from a
read/parse error (torn file, EMFILE, permissions): the latter is no longer
silently mis-read as 'signed out' (which flipped the billing gate to BYOK and
diverted usage to the unauthenticated queue for an authenticated user) — it
still returns null so callers stay simple, but logs the failure. (#12)1 parent 9f54034 commit 4677199
2 files changed
Lines changed: 48 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
339 | 344 | | |
340 | 345 | | |
341 | 346 | | |
| |||
359 | 364 | | |
360 | 365 | | |
361 | 366 | | |
362 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
363 | 374 | | |
364 | 375 | | |
365 | 376 | | |
366 | 377 | | |
367 | 378 | | |
368 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
369 | 382 | | |
370 | 383 | | |
371 | 384 | | |
| |||
402 | 415 | | |
403 | 416 | | |
404 | 417 | | |
405 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
406 | 422 | | |
| 423 | + | |
407 | 424 | | |
408 | 425 | | |
409 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
0 commit comments