summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 05:15:57 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit32198b59020e295efbc48de343a9de69c952dcfc (patch)
tree41e2c98839e844193fcd06f04f0f3aca4af3e252 /src/ninep
parent429c1e5e65afa4c65fa42bbb117c4b32a46a9470 (diff)
downloadpardes-32198b59020e295efbc48de343a9de69c952dcfc.tar.gz
pardes-32198b59020e295efbc48de343a9de69c952dcfc.zip
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 <[email protected]>
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/events.zig10
1 files changed, 10 insertions, 0 deletions
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: `<record> (x2)`, the count being every time it
/// was said. One a follower has already read is not rewritten: the repeat