Compare commits

...

3 commits

Author SHA1 Message Date
aec833f991 Merge pull request 'last_modified: don't find_blob; find the commit!' (!10) from fix-last_modified into main
Reviewed-on: #10
Reviewed-by: dinosaure <romain.calascibetta@gmail.com>
2024-12-20 12:11:31 +00:00
d2a0e526da Remove an assert false, and silence warning 8 2024-12-19 15:05:48 +01:00
e342f8539a last_modified: don't find_blob; find the commit!
To get the last_modified timestamp we need the commit object not the
blob. This is closer to the old behavior.
2024-12-18 16:22:30 +01:00

View file

@ -463,12 +463,19 @@ 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 ->
Store.read_exn t.store head >|= function
| Commit c ->
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 ->
(* See https://github.com/ocaml/ocaml/issues/9301 why we have the
intermediate [r] value. *)
let+ r = Store.read_exn t.store head in
let[@warning "-8"] Commit c = r in
let author = Git_commit.author c in
let secs, tz_offset = author.Git.User.date in
let secs =
@ -486,10 +493,6 @@ 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 ())))))
let digest t key =
let open Lwt.Infix in