╭ changed ───╮ │src/find.zig│ ╰────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │107 } │ │108 } │ │109 } │ │110 - │ │111 -// the action a file index refresh records when it runs on its own │ │112 -pub const undo_action = "haxy/find-index"; │ │113 - │ │114 -// reconcile every branch tip's index, in a transaction of its own │ │115 -pub fn refresh( │ │116 - comptime repo_opts: rp.RepoOpts(.xit), │ │117 - io: std.Io, │ │118 - allocator: std.mem.Allocator, │ │119 - repo: *rp.Repo(.xit, repo_opts), │ │120 -) !void { │ │121 - const Repo = rp.Repo(.xit, repo_opts); │ │122 - const DB = Repo.DB; │ │123 - const Save = struct { │ │124 - core: *Repo.Core, │ │125 - io: std.Io, │ │126 - allocator: std.mem.Allocator, │ │110 │ │128 - pub fn run(ctx: @This(), cursor: *DB.Cursor(.read_write)) !void { │ │129 - var moment = try DB.HashMap(.read_write).init(cursor.*); │ │130 - const state = Repo.State(.read_write){ .core = ctx.core, .extra = .{ .moment = &moment } }; │ │131 - if (!try refreshInTransaction(repo_opts, state, &moment, ctx.io, ctx.allocator, null)) return error.CancelTransaction; │ │132 - │ │133 - // record the user action for undo │ │134 - try xit.undo.write(repo_opts, state, std.Io.Timestamp.now(ctx.io, .real).toSeconds(), .{ .custom = .{ .action_kind = undo_action } }); │ │135 - } │ │136 - }; │ │137 - │ │138 - // held across the reads and the writes, so a concurrent refresh can't │ │139 - // change the entries these decisions were made from. │ │140 - try repo.core.db_file.lock(io, .exclusive); │ │141 - defer repo.core.db_file.unlock(io); │ │142 - │ │143 - const history = try DB.ArrayList(.read_write).init(repo.core.db.rootCursor()); │ │144 - history.appendContext(.{ .slot = try history.getSlot(-1) }, Save{ .core = &repo.core, .io = io, .allocator = allocator }) catch |err| switch (err) {│ │145 - error.CancelTransaction => {}, │ │146 - else => return err, │ │147 - }; │ │148 -} │ │149 - │ │111 // reconcile them inside the caller's transaction, so the index lands with the │ │112 // change that invalidated it. every branch is reconciled, since an up-to-date │ │113 // one costs a ref read and an oid compare. reports whether anything was │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯