about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-01-29 20:43:56 +0100
committerRobert Günzler <r@gnzler.io>2026-01-29 21:38:25 +0100
commit9dd7b684d504c2275c3ee999f661f4f40a2bb323 (patch)
tree9e39026ae4f71e4787d766884b566f9773ca70ec /src
parent746dc853786c8f060b87ac5abcd5fa1474b60321 (diff)
downloadsite-9dd7b684d504c2275c3ee999f661f4f40a2bb323.tar.gz
FileSwapper: track swapped state
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
-rw-r--r--src/fs.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/fs.zig b/src/fs.zig
index 4a3b049..08ad7ee 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -13,6 +13,7 @@ pub const FileSwapper = struct {
     target_path: []const u8,
     tmp_path: []const u8,
     tmp: std.fs.File,
+    swapped: *bool,
 
     pub fn createAt(alloc: std.mem.Allocator, path: []const u8) !FileSwapper {
         const target_dir = std.fs.path.dirname(path) orelse ".";
@@ -32,11 +33,15 @@ pub const FileSwapper = struct {
 
         const f = try std.fs.cwd().createFile(tmp_path, .{});
 
+        const swapped = try alloc.create(bool);
+        swapped.* = false;
+
         return .{
             .allocator = alloc,
             .target_path = path,
             .tmp_path = tmp_path,
             .tmp = f,
+            .swapped = swapped,
         };
     }
 
@@ -63,6 +68,8 @@ pub const FileSwapper = struct {
             std.fs.cwd(),
             self.target_path,
         );
+
+        self.swapped.* = true;
     }
 
     pub fn close(self: FileSwapper) void {