From cd712084c68b9e2bad350066a92a96ce78a9ff35 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 15:39:26 -0300 Subject: migration: a state file that holds no Recent yet reads it once from the files before it, 0.24's $XDG_STATE_HOME/pardes/recent (merged as another session's commit is), else the `store` before that (its `@r` records, the oldest first, as W4's one-time read did), and leaves both where they are (Options.recent_import names their directory, set by main.zig alone, so no test reads the user's); an old `.dump` file, the byte dump, stays readable for one release: `-l ` and `Restore ` read it, told from an image by its first bytes rather than by its name (the snapshot and process harnesses' dumps are `.dump.zon` files, and a renamed file is the same file), and an Upgrade from the build before, whose record names its `.dump` file and no label, loads it and deletes it as before, so the next Upgrade commits to the state file; tests: Db.zig's 'Recent is read once from the file it replaced, else from the store before that, both left where they are' (in place of W4's 'the store Recent's file replaced is read once, its newest records first, over the file's list'), dump.zig's 'an old dump's file, a byte dump, is read by -l and by a Restore of its path, for one release', and upgrade.zig's 'an upgrade from the build before reads the dump file its record names, and deletes it once loaded' Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/main.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 3b7d6abe..afa72881 100644 --- a/src/main.zig +++ b/src/main.zig @@ -744,6 +744,7 @@ fn nativeMain(std_init: std.process.Init) !void { opts.startup_config_path = found.path; opts.config_dir = found.dir; opts.state = .disk; + opts.recent_import = oldRecentDir(arena, init.environ_map); if (found.dir) |d| @import("crash.zig").setDir(d); if (attach) |name| if (std.mem.lastIndexOfScalar(u8, name, ':')) |colon| { remoteAttach(init, opts, name[0..colon], name[colon + 1 ..]); @@ -1099,3 +1100,14 @@ test { if (comptime pardes.platform == .gui) _ = @import("gui/gui.zig"); if (comptime pardes.font_picker) _ = @import("fonts.zig"); } + +/// Where Recent's file (0.24) and the store before it were kept: +/// $XDG_STATE_HOME/pardes, else ~/.local/state/pardes. A state file that +/// holds no Recent yet reads them once (Db.zig). +fn oldRecentDir(arena: std.mem.Allocator, env: *const std.process.Environ.Map) ?[]const u8 { + if (env.get("XDG_STATE_HOME")) |base| if (base.len != 0 and std.fs.path.isAbsolute(base)) + return std.fs.path.join(arena, &.{ base, "pardes" }) catch null; + const home = env.get("HOME") orelse return null; + if (home.len == 0) return null; + return std.fs.path.join(arena, &.{ home, ".local", "state", "pardes" }) catch null; +} -- cgit v1.3