protondrive: read volume events and invalidate the cache from them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-11-12 16:05:46 +01:00
1 parent d607fc6581
commit 877bb5d10c
8 files changed
+783 -6

No files matched your search

+5 -5
View File
@@ -123,11 +123,11 @@ prefix, Proton's exact JSON field names. In addition:
- `func (n *nodeCache) invalidateTree(id string)` and `func (n *nodeCache) empty() bool` (nil cache: `empty` is true).
- `errVolumeGone` returned by both calls on code 2501.
- [ ] **Step 1: Write failing tests**: `TestLatestEventID`; `TestPollEventsPages` (fake page size 2, 7 changes: all 7 returned in order, `next` equals the fake's newest ID); `TestPollEventsRefresh`; `TestPollEventsVolumeGone` (`errors.Is(err, errVolumeGone)`); `TestApplyEventsInvalidates` (table per event kind with a warmed cache: which nodes and listings are gone afterwards, and the returned `staleNode` values); `TestInvalidateTree` (folder with nested cached children: all gone, unrelated nodes kept, in-flight listing guard bumped); `TestNodeCacheEmpty`; `FuzzDecodeEvents` (arbitrary JSON into `api.EventsResponse` and through `applyEvents` on a small cache: no panic).
- [ ] **Step 2: Run** `RCLONE_CONFIG=/notfound go test ./backend/protondrive/ -run 'Event|InvalidateTree|NodeCacheEmpty' -v` - expect FAIL.
- [ ] **Step 3: Implement** in `events.go` (no `fs.Fs` types; logging only through `fs.Debugf`/`fs.Errorf`).
- [ ] **Step 4: Run** the tests, then `go test -run '^$' -fuzz FuzzDecodeEvents -fuzztime 20s ./backend/protondrive/` - expect PASS, no crash.
- [ ] **Step 5: Commit** `protondrive: read volume events and invalidate the cache from them`.
- [x] **Step 1: Write failing tests**: `TestLatestEventID`; `TestPollEventsPages` (fake page size 2, 7 changes: all 7 returned in order, `next` equals the fake's newest ID); `TestPollEventsRefresh`; `TestPollEventsVolumeGone` (`errors.Is(err, errVolumeGone)`); `TestApplyEventsInvalidates` (table per event kind with a warmed cache: which nodes and listings are gone afterwards, and the returned `staleNode` values); `TestInvalidateTree` (folder with nested cached children: all gone, unrelated nodes kept, in-flight listing guard bumped); `TestNodeCacheEmpty`; `FuzzDecodeEvents` (arbitrary JSON into `api.EventsResponse` and through `applyEvents` on a small cache: no panic).
- [x] **Step 2: Run** `RCLONE_CONFIG=/notfound go test ./backend/protondrive/ -run 'Event|InvalidateTree|NodeCacheEmpty' -v` - expect FAIL.
- [x] **Step 3: Implement** in `events.go` (no `fs.Fs` types; logging only through `fs.Debugf`/`fs.Errorf`).
- [x] **Step 4: Run** the tests, then `go test -run '^$' -fuzz FuzzDecodeEvents -fuzztime 20s ./backend/protondrive/` - expect PASS, no crash.
- [x] **Step 5: Commit** `protondrive: read volume events and invalidate the cache from them`.
### Task 3: The poller