Skip to content

Commit

Permalink
Update irmin-server/client API for new clear arg
Browse files Browse the repository at this point in the history
  • Loading branch information
metanivek committed Aug 2, 2023
1 parent 4a34601 commit 4046041
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/irmin-client/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -702,16 +702,18 @@ struct
let repo = repo store in
request repo (module Commands.Store.Find) path >|= Error.unwrap "find"

let remove_exn ?retries ?allow_empty ?parents ~info store path =
let remove_exn ?clear ?retries ?allow_empty ?parents ~info store path =
let parents = Option.map (List.map (fun c -> Commit.hash c)) parents in
let repo = repo store in
request repo
(module Commands.Store.Remove)
((retries, allow_empty, parents), path, info ())
(((clear, retries), (allow_empty, parents)), path, info ())
>|= Error.unwrap "remove"

let remove ?retries ?allow_empty ?parents ~info store path =
let* x = remove_exn ?retries ?allow_empty ?parents ~info store path in
let remove ?clear ?retries ?allow_empty ?parents ~info store path =
let* x =
remove_exn ?clear ?retries ?allow_empty ?parents ~info store path
in
Lwt.return_ok x

let find_tree store path =
Expand Down
10 changes: 6 additions & 4 deletions src/irmin-server/command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ struct
Return.v conn res_t (Some x)
end

type write_options = int option * bool option * Store.hash list option
type write_options =
(bool option * int option) * (bool option * Store.hash list option)
[@@deriving irmin]

let mk_parents ctx parents =
Expand All @@ -613,11 +614,12 @@ struct

let name = "store.remove"

let run conn ctx _ ((retries, allow_empty, parents), path, info) =
let run conn ctx _
(((clear, retries), (allow_empty, parents)), path, info) =
let* parents = mk_parents ctx parents in
let* () =
Store.remove_exn ?retries ?allow_empty ?parents ctx.store path
~info:(fun () -> info)
Store.remove_exn ?clear ?retries ?allow_empty ?parents ctx.store
path ~info:(fun () -> info)
in
Return.v conn res_t ()
end
Expand Down
6 changes: 4 additions & 2 deletions src/irmin-server/command_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ module type S = sig

(* Store *)
module Store : sig
type write_options = int option * bool option * Store.hash list option
type write_options =
(bool option * int option) * (bool option * Store.hash list option)
[@@deriving irmin]

(** Find a value in the store *)
Expand All @@ -301,7 +302,8 @@ module type S = sig
module Remove :
CMD
with type req =
(int option * bool option * Store.hash list option)
((bool option * int option)
* (bool option * Store.hash list option))
* Store.path
* Store.Info.t
and type res = unit
Expand Down

0 comments on commit 4046041

Please sign in to comment.