diff options
Diffstat (limited to 'src/Store.zig')
| -rw-r--r-- | src/Store.zig | 20 |
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; |
