From 90530f893236c665deb9f5bddc925ee1fe51cca5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 23:13:57 -0300 Subject: A failed Dump or a Restore of no dump fails its write, before any warning A Dump into a DumpDir it could not write, or a Restore of a file that is not a dump, answered a ctl write with rc 0 and only a message, and the Restore warned about unsaved panes before it ever looked at the file. The hosts' dump write now fails the waiting 9P write with EIO (the late failure a Save uses), naming the path and the reason in the log, and Restore parses the file before its unsaved-panes refusal, failing with `not a pardes dump`. Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 452f6174..c2bde804 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5105,6 +5105,20 @@ pub const Pardes = struct { p.fs.late_failure_len = @intCast(kept.len); } + /// A Dump the host could not write: said on the message row and in the + /// log, and the 9P write that asked for it fails with it, as a failed + /// Save's does. + pub fn dumpFailed(p: *Pardes, path: []const u8, err: anyerror) void { + var what: [limits.host_path_cap + 8]u8 = undefined; + const operation = std.fmt.bufPrint(&what, "Dump {s}", .{path}) catch "Dump"; + p.reportError(p.active, operation, err); + var buf: [256]u8 = undefined; + const said = std.fmt.bufPrint(&buf, "{s}: {s}", .{ operation, @errorName(err) }) catch "Dump failed"; + const kept = @import("Messages.zig").clip(said, p.fs.late_failure.len); + @memcpy(p.fs.late_failure[0..kept.len], kept); + p.fs.late_failure_len = @intCast(kept.len); + } + /// The path a watch is about: a real file's, or a PDF's. fn watchPath(p: *const Pardes, id: u8) ?[]const u8 { const pane = p.panes[id] orelse return null; -- cgit v1.3