Skip to content

Commit

Permalink
Update flush, close and reload to return `Ro_not_allowed instead of r…
Browse files Browse the repository at this point in the history
…aising exception
  • Loading branch information
zshipko committed Aug 10, 2022
1 parent b5d5e3f commit ec751b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/irmin-pack/unix/file_manager_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ module type S = sig
| `Unknown_major_pack_version of string
| `Inconsistent_store
| `Invalid_argument
| `Read_out_of_bounds ]
| `Read_out_of_bounds
| `Ro_not_allowed ]

val open_ro : Irmin.Backend.Conf.t -> (t, [> open_ro_error ]) result
(** Note on SWMR consistency: TODO: doc
Expand All @@ -126,7 +127,8 @@ module type S = sig
[ `Double_close
| `Index_failure of string
| `Io_misc of Io.misc_error
| `Pending_flush ]
| `Pending_flush
| `Ro_not_allowed ]

val close : t -> (unit, [> close_error ]) result
(** Close all the files.
Expand Down
7 changes: 4 additions & 3 deletions src/irmin-pack/unix/pack_index.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(*
* Copyright (c) 2018-2022 Tarides <contact@tarides.com>
*
* Permission to use, copy, modify, and distribute this software for any
Expand Down Expand Up @@ -93,7 +94,7 @@ module Make (K : Irmin.Hash.S) = struct
close_exn t;
Ok ()
with
| I.RO_not_allowed -> assert false
| I.RO_not_allowed -> Error `Ro_not_allowed
| Index_unix.Private.Raw.Not_written -> assert false
| Unix.Unix_error (x, y, z) -> Error (`Io_misc (x, y, z))
| Failure msg -> Error (`Index_failure msg)
Expand All @@ -103,7 +104,7 @@ module Make (K : Irmin.Hash.S) = struct
Index.sync t;
Ok ()
with
| I.RO_not_allowed -> assert false
| I.RO_not_allowed -> Error `Ro_not_allowed
| Index_unix.Private.Raw.Not_written -> assert false
| Unix.Unix_error (x, y, z) -> Error (`Io_misc (x, y, z))
| Failure msg -> Error (`Index_failure msg)
Expand All @@ -113,7 +114,7 @@ module Make (K : Irmin.Hash.S) = struct
Index.flush ~no_callback:() ~with_fsync t;
Ok ()
with
| I.RO_not_allowed -> assert false
| I.RO_not_allowed -> Error `Ro_not_allowed
| Index_unix.Private.Raw.Not_written -> assert false
| Unix.Unix_error (x, y, z) -> Error (`Io_misc (x, y, z))
| Failure msg -> Error (`Index_failure msg)
Expand Down
5 changes: 4 additions & 1 deletion src/irmin-pack/unix/pack_index_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ module type S = sig
string ->
t

type error := [ `Index_failure of string | `Io_misc of Io.Unix.misc_error ]
type error :=
[ `Index_failure of string
| `Io_misc of Io.Unix.misc_error
| `Ro_not_allowed ]

val v :
?flush_callback:(unit -> unit) ->
Expand Down
3 changes: 2 additions & 1 deletion src/irmin-pack/unix/snapshot_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ module type Sigs = sig
[> `Double_close
| `Index_failure of string
| `Io_misc of Fm.Io.misc_error
| `Pending_flush ] )
| `Pending_flush
| `Ro_not_allowed ] )
result
end

Expand Down

0 comments on commit ec751b3

Please sign in to comment.