summaryrefslogtreecommitdiff
path: root/src/Store.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:28:52 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:00:59 -0300
commit43739b4eb99f2b68ec2368e6ec69491b2d9ab0b4 (patch)
tree13a088e2ab1629b520eb178e2ff972aab8675c74 /src/Store.zig
parentb6e7d53f6700988c33266b20eb3505bc3471451b (diff)
downloadpardes-43739b4eb99f2b68ec2368e6ec69491b2d9ab0b4.tar.gz
pardes-43739b4eb99f2b68ec2368e6ec69491b2d9ab0b4.zip
recent: the old `recent` file's import goes (List.read and Store.load's branch for a store not made yet, the store in use since 2026-10-24), and with it List.write, the format's other half only its test used; closed takes the selection's anchor itself, closedSel its only caller's spelling; recent.zig's test reads a record back through parseLine, docs/next-store.md says the import went
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Store.zig')
-rw-r--r--src/Store.zig20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/Store.zig b/src/Store.zig
index 9c726705..87dba4f7 100644
--- a/src/Store.zig
+++ b/src/Store.zig
@@ -293,23 +293,13 @@ fn parseMeta(body: []const u8) ?Meta {
return m;
}
-/// The store read at start; the old `recent` file beside it read into the
-/// list once, when there is no store yet, so nobody's list is lost.
+/// The store read at start.
pub fn load(s: *Store, p: *Pardes) void {
const path = s.path orelse return;
if (comptime !pardes.hosted) return;
defer s.loaded = true;
const io = ioOf();
- const file = host(Dir.openFile, .{ cwd(), io, path, Dir.OpenFileOptions{} }) catch |err| {
- if (err != error.FileNotFound) return;
- const dir = std.fs.path.dirname(path) orelse return;
- var buf: [4096 + 16]u8 = undefined;
- const old = std.fmt.bufPrint(&buf, "{s}/recent", .{dir}) catch return;
- const bytes = host(Dir.readFileAlloc, .{ cwd(), io, old, p.gpa, std.Io.Limit.limited(1 << 20) }) catch return;
- defer p.gpa.free(bytes);
- p.recent.read(p.recentGpa(), bytes);
- return;
- };
+ const file = host(Dir.openFile, .{ cwd(), io, path, Dir.OpenFileOptions{} }) catch return;
defer host(File.close, .{ file, io });
const st = host(File.stat, .{ file, io }) catch return;
s.readFile(p, file, st);
@@ -932,7 +922,7 @@ test "store: two windows share Recent, each reading the other's writes on use; a
a.saveRecent();
b.recent.opened(b.recentGpa(), "/w/b.zig");
b.saveRecent();
- a.recent.closed(a.recentGpa(), "/w/a.zig", 7, 3);
+ a.recent.closed(a.recentGpa(), "/w/a.zig", 7, 3, 0, 0);
a.saveRecent();
// Each has both, in the order of the log: a closed last, then b.
a.store.refresh(a);
@@ -981,7 +971,7 @@ test "store: the cap holds, compaction keeps the newest, Recent keeps its 200" {
for (0..3000) |i| {
const file = std.fmt.bufPrint(&name, "/w/file{d}.zig", .{i}) catch unreachable;
a.recent.opened(a.recentGpa(), file);
- a.recent.closed(a.recentGpa(), file, 1, 1);
+ a.recent.closed(a.recentGpa(), file, 1, 1, 0, 0);
a.saveRecent();
try testing.expect(fileSize(path) <= a.store.cap);
if (a.store.inode != last_inode) inodes += 1;
@@ -1192,7 +1182,7 @@ test "zz store timings on a 90 MiB store (STORE_TIMES=<dir>)" {
for (0..100) |i| {
const f = std.fmt.bufPrint(&name, "/w/new{d}.zig", .{i}) catch unreachable;
p.recent.opened(p.recentGpa(), f);
- p.recent.closed(p.recentGpa(), f, 1, 1);
+ p.recent.closed(p.recentGpa(), f, 1, 1, 0, 0);
p.saveRecent();
}
const flush_ns = (nowNs() - t) / 100;