aboutsummaryrefslogtreecommitdiffstats
path: root/lib/disk.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2024-10-27 15:29:49 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2024-11-02 20:07:39 -0300
commitb2bdbce941256a8ffc52af09023bb75b4372276d (patch)
treeaded4defc21a1e0b601d27a8d30ab7b56320b356 /lib/disk.ml
parentb5dbdaa989a86477669aac0bf342029e1d2b6028 (diff)
downloadSakura-b2bdbce941256a8ffc52af09023bb75b4372276d.tar.gz
Sakura-b2bdbce941256a8ffc52af09023bb75b4372276d.zip
clean
Diffstat (limited to '')
-rw-r--r--lib/disk.ml9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/disk.ml b/lib/disk.ml
index aa971dd..fc99607 100644
--- a/lib/disk.ml
+++ b/lib/disk.ml
@@ -191,12 +191,13 @@ module Command = struct
(** TODO: This does not write atomically. If the system crashes while it attempts to write, it will corrupt.
Solve this with a temporary file and move later. *)
- let commit
- (* (_files: Filesystem.files) (_locations: Filesystem.locations) *)
- command =
+ let commit_and_perform (commit: Executor.commit) (locations: Executor.locations) command =
let open Extensions.Result in
let+ serialized_command =
Result.map_error (fun _ -> "Failed to serialize command to binary format.")
@@ Binary.to_bytes command_encoding command in
- FS.append FS.Transaction serialized_command
+ let+ _ = FS.append FS.Transaction serialized_command in
+ match command.kind with
+ | WRITE -> Executor.write commit locations ~filename:command.filename @@ Bytes.of_string command.content
+ | _ -> Ok (commit, locations)
end