Compare commits
No commits in common. "aec833f991fbccf93b95c9daba3836922ad1f634" and "a6ebf32529650236fa2879e88b52880335c291d7" have entirely different histories.
aec833f991
...
a6ebf32529
1 changed files with 27 additions and 30 deletions
|
@ -463,36 +463,33 @@ module Make (Pclock : Mirage_clock.PCLOCK) = struct
|
|||
|
||||
let last_modified t key =
|
||||
let open Lwt.Infix in
|
||||
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 =
|
||||
Option.fold ~none:secs
|
||||
~some:(fun { Git.User.sign ; hours ; minutes } ->
|
||||
let tz_off = Int64.(mul (add (mul (of_int hours) 60L) (of_int minutes)) 60L) in
|
||||
match sign with
|
||||
| `Plus -> Int64.(sub secs tz_off)
|
||||
| `Minus -> Int64.(add secs tz_off))
|
||||
tz_offset
|
||||
in
|
||||
let ts =
|
||||
Option.fold
|
||||
~none:Ptime.epoch
|
||||
~some:Fun.id (Ptime.of_float_s (Int64.to_float secs))
|
||||
in
|
||||
Ok ts
|
||||
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 ->
|
||||
let author = Git_commit.author c in
|
||||
let secs, tz_offset = author.Git.User.date in
|
||||
let secs =
|
||||
Option.fold ~none:secs
|
||||
~some:(fun { Git.User.sign ; hours ; minutes } ->
|
||||
let tz_off = Int64.(mul (add (mul (of_int hours) 60L) (of_int minutes)) 60L) in
|
||||
match sign with
|
||||
| `Plus -> Int64.(sub secs tz_off)
|
||||
| `Minus -> Int64.(add secs tz_off))
|
||||
tz_offset
|
||||
in
|
||||
let ts =
|
||||
Option.fold
|
||||
~none:Ptime.epoch
|
||||
~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
|
||||
|
|
Loading…
Reference in a new issue