summaryrefslogtreecommitdiff
path: root/src/Store.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Store.zig')
-rw-r--r--src/Store.zig21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Store.zig b/src/Store.zig
index 35033e04..e06c55e5 100644
--- a/src/Store.zig
+++ b/src/Store.zig
@@ -599,16 +599,10 @@ pub fn close(s: *Store, p: *Pardes, k: Kept, gainer: ?usize) void {
pub fn flush(s: *Store, p: *Pardes, wait: bool) void {
const gpa = p.recentGpa();
if (!p.recent.dirty and s.pending.items.len == 0) return;
- const path = if (comptime pardes.hosted) s.path else null;
- if (path == null or !s.loaded) {
- if (path == null) {
- for (p.recent.entries.items) |*e| e.changed = false;
- p.recent.dirty = false;
- s.pending.clearRetainingCapacity();
- for (s.closed.items) |*c| c.pending_at = null;
- }
- return;
- }
+ // No file: nothing to write it to, ever.
+ if (comptime !pardes.hosted) return s.forget(p);
+ const path: ?[]const u8 = s.path orelse return s.forget(p);
+ if (!s.loaded) return;
const io = ioOf();
var name_buf: [4096 + 16]u8 = undefined;
const lock_path = std.fmt.bufPrint(&name_buf, "{s}.lock", .{path.?}) catch return;
@@ -658,6 +652,13 @@ pub fn flush(s: *Store, p: *Pardes, wait: bool) void {
s.pending.clearRetainingCapacity();
}
+fn forget(s: *Store, p: *Pardes) void {
+ for (p.recent.entries.items) |*e| e.changed = false;
+ p.recent.dirty = false;
+ s.pending.clearRetainingCapacity();
+ for (s.closed.items) |*c| c.pending_at = null;
+}
+
fn dropPending(s: *Store, gpa: std.mem.Allocator) void {
_ = gpa;
s.pending.clearRetainingCapacity();