less exceptions

This commit is contained in:
Hannes Mehnert 2022-09-20 13:27:49 +02:00
parent 65c8202565
commit d124201bf3

View file

@ -64,7 +64,9 @@ let disconnect _t = Lwt.return_unit
let to_octets t = let to_octets t =
let open Lwt.Infix in let open Lwt.Infix in
let head = Option.get t.head in match t.head with
| None -> Lwt.return ""
| Some head ->
Store.read_exn t.store head >|= function Store.read_exn t.store head >|= function
| Commit c -> | Commit c ->
let l = Encore.to_lavoisier Git_commit.format in let l = Encore.to_lavoisier Git_commit.format in
@ -90,7 +92,9 @@ let exists _t _key =
let get t key = let get t key =
let open Lwt.Infix in let open Lwt.Infix in
let head = Option.get t.head in match t.head with
| None -> Lwt.return (Error (`Not_found key))
| Some head ->
Search.find t.store head (`Path (Mirage_kv.Key.segments key)) >>= function Search.find t.store head (`Path (Mirage_kv.Key.segments key)) >>= function
| None -> Lwt.return (Error (`Not_found key)) | None -> Lwt.return (Error (`Not_found key))
| Some blob -> | Some blob ->
@ -116,8 +120,7 @@ let last_modified _t _key =
assert false assert false
let digest t _key = let digest t _key =
let head = Option.get t.head in Lwt.return (Ok (Option.fold ~none:"0" ~some:Store.Hash.to_hex t.head))
Digestif.SHA1.to_hex head
let size t key = let size t key =
let open Lwt_result.Infix in let open Lwt_result.Infix in