Remove redundant Store.with_id

master
orbifx 3 months ago
parent bfc8195a31
commit 977462fc5a
  1. 12
      lib/file_store.ml
  2. 1
      lib/store.ml

@ -94,18 +94,6 @@ let fold ?(r=false) ?(dir=def_dir ()) ?(predicate=fun _ -> true) ?order ?number
| None -> List.fold_left fn acc @@ TextMap.bindings @@
List.fold_left (fold_valid_text predicate) new_iteration flist
let with_id ?(r=false) ?(dir=def_dir ()) id =
let matched acc path =
match to_text path with
| Error x -> prerr_endline x; acc
| Ok text when text.Text.id <> id -> acc
| Ok text ->
match acc with
| Ok None -> Ok (Some text)
| Ok (Some prev) -> if prev = text then acc else Error [text; prev]
| Error x -> Error (text :: x)
in List.fold_left matched (Ok None) (list_fs ~r dir)
let with_dir ?(descr="") ?(perm=0o740) dir =
let mkdir dir = match Unix.mkdir dir perm with
| exception Unix.Unix_error (EEXIST, _, _) -> ()

@ -8,7 +8,6 @@ module type T = sig
val of_path: string -> (archive_t, string) result
val newest: record_t -> record_t -> int
val oldest: record_t -> record_t -> int
val with_id: archive_t -> Id.t -> (Text.t option, Text.t list) result
val with_text: archive_t -> Text.t -> (string * Text.t, string) result
val iter: ?predicate:(Text.t -> bool) -> ?order:(record_t -> record_t -> int) -> ?number:int
-> (record_t -> unit) -> archive_t -> unit

Loading…
Cancel
Save