diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 11:30:18 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 5e8d2b7ac7d7880ac36ec45484b2711669ac7ae1 (patch) | |
| tree | d8c84364f51e3d9e136d5ad4e196235e12d37f66 /src/Messages.zig | |
| parent | fda2f546f66d0bb1b30da0ef6aae77fe82803b1c (diff) | |
| download | pardes-5e8d2b7ac7d7880ac36ec45484b2711669ac7ae1.tar.gz pardes-5e8d2b7ac7d7880ac36ec45484b2711669ac7ae1.zip | |
A failure naming a long path keeps its reason, and name refuses a component over 255 bytes
A Save of a 3000-byte path failed with the record "err 2 ctl: Save…", which
lost the reason. The first cause was reportError, which formatted into 256
bytes, so the operation's path filled the buffer before the reason was
written. The second was the waiting write's late failure, which took the
first 256 bytes of the message row, never its end. Now reportError has room
for the longest path. reportFailure also keeps the words fitted as an err is
(fitErr: the path gives up its middle, the reason stays), and the late
failure of a Save, a Dump, a shell or a ThemeFile takes those words.
fs.md already said a name holds up to 255 bytes a component, but a longer
one was taken and only failed later at Save. Now it is refused when written.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Messages.zig')
| -rw-r--r-- | src/Messages.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Messages.zig b/src/Messages.zig index d1478ac7..3eeb8c92 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -463,7 +463,10 @@ pub fn dialReason(err: anyerror) ?[]const u8 { } pub fn reportError(p: *Pardes, id: usize, operation: []const u8, err: anyerror) void { - var buf: [256]u8 = undefined; + // Room for an operation naming the longest path and the reason after + // it: a shorter one cut the reason off (`Save /long…`), and the reason + // is what a failure is for. Where it must be shorter, the path gives. + var buf: [@max(256, limits.host_path_cap + 128)]u8 = undefined; var w = std.Io.Writer.fixed(&buf); w.print("{s}: ", .{operation}) catch {}; // A peer out of reach says so, not the error's name (`dial`). @@ -503,6 +506,11 @@ pub fn clip(text: []const u8, max: usize) []const u8 { /// reportError with the words already chosen. pub fn reportFailure(p: *Pardes, id: usize, text: []const u8) void { p.fs.failures +%= 1; + var fitted: @TypeOf(p.fs.said) = undefined; + const said = pardes.ctlfs.fitErr(text, &fitted); + @memcpy(p.fs.said[0..said.len], said); + p.fs.said_len = @intCast(said.len); + p.fs.said_at = p.fs.failures; // A builtin a ctl write runs: its first error is also the write's, its // path shortened in the middle if it must be, never its reason. const failing_write = p.fs.no_prompt or p.fs.capturing or p.fs.write_waits; |
