last_modified: don't find_blob; find the commit! #10

Merged
reynir merged 2 commits from fix-last_modified into main 2024-12-20 12:11:32 +00:00
Showing only changes of commit e342f8539a - Show all commits

View file

@ -463,10 +463,15 @@ module Make (Pclock : Mirage_clock.PCLOCK) = struct
let last_modified t key = let last_modified t key =
let open Lwt.Infix in let open Lwt.Infix in
find_blob t key >>= match t.committed, t.head with
Option.fold | None, None ->
~none:(Lwt.return (Error (`Not_found key))) Lwt.return (Error (`Not_found key))
~some:(fun head -> | Some _, _ ->
Lwt.return_ok
(Option.fold
~none:Ptime.epoch
~some:Fun.id (Ptime.of_float_s (Int64.to_float (now ()))))
| None, Some head ->
Store.read_exn t.store head >|= function Store.read_exn t.store head >|= function
| Commit c -> | Commit c ->
let author = Git_commit.author c in let author = Git_commit.author c in
@ -486,10 +491,7 @@ module Make (Pclock : Mirage_clock.PCLOCK) = struct
~some:Fun.id (Ptime.of_float_s (Int64.to_float secs)) ~some:Fun.id (Ptime.of_float_s (Int64.to_float secs))
in in
Ok ts Ok ts
| _ -> | _ -> assert false
Ok (Option.fold
~none:Ptime.epoch
~some:Fun.id (Ptime.of_float_s (Int64.to_float (now ())))))
let digest t key = let digest t key =
let open Lwt.Infix in let open Lwt.Infix in