diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-08 20:52:15 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-08 21:48:19 -0300 |
| commit | 76f1355649e81d5ab28c591461d07440d26902b0 (patch) | |
| tree | 52d357d857caec9c946e005119e05d314a1dd6f6 | |
| parent | 1f7f9920155b574e0d0e8a94054b596f36e2c065 (diff) | |
| download | pardes-76f1355649e81d5ab28c591461d07440d26902b0.tar.gz pardes-76f1355649e81d5ab28c591461d07440d26902b0.zip | |
fix: Recent's one-time import from the files before the state file read nothing, and said nothing, for a directory whose path passed its room (a bufPrint caught to ""): a directory past max_path_bytes is said in the message, Recent: the files before the state file were not read: their directory's path is N bytes, too long; the import test gains such a window
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | src/Db.zig | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -361,6 +361,10 @@ fn importRecent(p: *Pardes, dir: []const u8) void { const gpa = p.recentGpa(); const io = ioOf(); var path_buf: [4200]u8 = undefined; + if (dir.len + "/recent".len >= std.Io.Dir.max_path_bytes) { + var said: [160]u8 = undefined; + return p.setMessage(p.view().active, std.fmt.bufPrint(&said, "Recent: the files before the state file were not read: their directory's path is {d} bytes, too long", .{dir.len}) catch unreachable); // a number fits 160 + } pardes.turn.yield(); const listed = std.Io.Dir.cwd().readFileAlloc(io, std.fmt.bufPrint(&path_buf, "{s}/recent", .{dir}) catch "", gpa, .limited(recent_max)) catch null; const logged = if (listed == null) std.Io.Dir.cwd().readFileAlloc(io, std.fmt.bufPrint(&path_buf, "{s}/store", .{dir}) catch "", gpa, .limited(128 << 20)) catch null else null; @@ -1397,6 +1401,19 @@ test "state file: Recent is read once from the file it replaced, else from the s try testing.expectEqual(@as(u32, 9), b.recent.entries.items[0].line); try testing.expectEqualStrings("/w/both.zig", b.recent.entries.items[1].path); } + // A directory whose path is past the room for its files' names: none + // read, and said so. + { + try tmp.dir.createDirPath(testing.io, "c"); + var long: [4200]u8 = undefined; + @memset(&long, 'd'); + long[0] = '/'; + const c = try window(try std.fmt.bufPrint(&buf[2], "{s}/c", .{dir}), &long); + defer c.deinit(); + try testing.expectEqual(@as(usize, 0), c.recent.entries.items.len); + const pane = c.panes[c.view().active].?; + try testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "Recent: the files before the state file were not read") != null); + } // Both left where they were. _ = try tmp.dir.statFile(testing.io, "old/recent", .{}); _ = try tmp.dir.statFile(testing.io, "older/store", .{}); |
