last_modified: don't find_blob; find the commit! #10
1 changed files with 29 additions and 27 deletions
|
@ -463,10 +463,15 @@ module Make (Pclock : Mirage_clock.PCLOCK) = struct
|
|||
|
||||
let last_modified t key =
|
||||
let open Lwt.Infix in
|
||||
find_blob t key >>=
|
||||
Option.fold
|
||||
~none:(Lwt.return (Error (`Not_found key)))
|
||||
~some:(fun head ->
|
||||
match t.committed, t.head with
|
||||
| None, None ->
|
||||
Lwt.return (Error (`Not_found key))
|
||||
| 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
|
||||
| Commit c ->
|
||||
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))
|
||||
in
|
||||
Ok ts
|
||||
| _ ->
|
||||
Ok (Option.fold
|
||||
~none:Ptime.epoch
|
||||
~some:Fun.id (Ptime.of_float_s (Int64.to_float (now ())))))
|
||||
| _ -> assert false
|
||||
|
||||
let digest t key =
|
||||
let open Lwt.Infix in
|
||||
|
|
Loading…
Reference in a new issue