repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

caldav: fix applyFetch treating failed fetch as success

d29e081829c61e9b94f9073a59cc580f864ca512

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Adversarial review caught it: fetchScript prints @@CAL headers before curl
runs, so on an HTTP-level failure (e.g. 401 returns an error body, curl
exits 0, nothing on stderr) stdout is non-empty but carries zero
calendar-data blocks. The old guard 'if (!t.trim())' was false, so the
code fell through to status=ok stale=false with an empty event list —
a failed refresh masquerading as success.

Guard on the 207 <d:multistatus> wrapper instead: present on any
successful REPORT (including an empty month, so no false stale), absent on
auth/transport failure. Verified live: real fetch still status=ok, 155
events, stale=false.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (1)

+5 / −1 text lines

Diff layout

quickshell/nuguland/CalDav.qml

Modified

+5 / −1 text lines

202202 if (t.indexOf("__NO_SECRET__") >= 0) { root.status = "needs-setup"; return; }
203203 let parsed = [];
204204 try { parsed = Ical.parseIcs(t); } catch (e) { parsed = []; }
205 if (!t.trim()) { root.status = "offline"; root.stale = true; return; } // keep last-good events
205 // a successful REPORT is a 207 <d:multistatus>; its absence means a
206 // transport/auth failure (curl prints @@CAL headers but no data), so
207 // t is non-empty yet useless — keep last-good events and flag stale.
208 // (an empty month still returns multistatus, so this won't false-trip.)
209 if (t.indexOf("multistatus") < 0) { root.status = "offline"; root.stale = true; return; }
206210 // client-side window filter for tasks (VTODO has no server time-range)
207211 const gs = root.gridStartDate();
208212 const winStart = gs, winEnd = Ical.addDays(gs, 42);