From 32198b59020e295efbc48de343a9de69c952dcfc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 05:15:57 -0300 Subject: A Save that fails logs its err, not a save record The save record was logged as soon as the host was asked to write, so a Save into a read-only directory logged save and then failed. It is now logged only once the write is done; a failure's err record (the write's, naming the path) stands alone, the msg it was also said as dropped. Co-Authored-By: Claude Opus 5.5 --- src/ninep/events.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ninep') diff --git a/src/ninep/events.zig b/src/ninep/events.zig index 7a06bd04..d2beecd1 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -226,6 +226,16 @@ pub fn dropAnnouncement(p: *Pardes, serial: u32, text: []const u8) void { p.fs.log.buf.shrinkRetainingCapacity(last.at); } +/// Drops the newest record when it is a msg saying `text` (of any pane) +/// that no follower has read: a failure its write's err record will say. +pub fn dropMessage(p: *Pardes, text: []const u8) void { + const last = newest(p) orelse return; + if (followerRead(p, last.seq) or !std.mem.startsWith(u8, last.text, "msg ")) return; + const rest = last.text["msg ".len..]; + const sp = std.mem.indexOfScalar(u8, rest, ' ') orelse return; + if (std.mem.eql(u8, rest[sp + 1 ..], text)) p.fs.log.buf.shrinkRetainingCapacity(last.at); +} + /// Pushes `record`, or, when it repeats the newest record word for word, /// counts that one instead: ` (x2)`, the count being every time it /// was said. One a follower has already read is not rewritten: the repeat -- cgit v1.3