use git-kv 0.0.5+ API for to/of_octets #17
2 changed files with 6 additions and 3 deletions
|
@ -8,7 +8,7 @@ let mirror =
|
|||
package "h2" ;
|
||||
package "ohex" ;
|
||||
package "httpaf" ;
|
||||
package ~max:"0.0.5" "git-kv" ;
|
||||
package ~min:"0.0.5" "git-kv" ;
|
||||
package ~min:"3.10.0" "git-paf" ;
|
||||
package "opam-file-format" ;
|
||||
package ~min:"3.0.0" ~sublibs:[ "gz" ] "tar" ;
|
||||
|
|
|
@ -902,7 +902,9 @@ stamp: %S
|
|||
Logs.info (fun m -> m "downloading of %d urls done" (SM.cardinal urls))
|
||||
|
||||
let dump_git git_dump git_kv =
|
||||
Git_kv.to_octets git_kv >>= fun data ->
|
||||
let stream = Git_kv.to_octets git_kv in
|
||||
Lwt_stream.to_list stream >>= fun datas ->
|
||||
let data = String.concat "" datas in
|
||||
Cache.write git_dump data >|= function
|
||||
| Ok () ->
|
||||
Logs.info (fun m -> m "dumped git %d bytes" (String.length data))
|
||||
|
@ -916,7 +918,8 @@ stamp: %S
|
|||
Logs.warn (fun m -> m "failed to read git state: %a" Cache.pp_error e);
|
||||
Lwt.return (Error ())
|
||||
| Ok Some data ->
|
||||
Git_kv.of_octets git_ctx ~remote data >|= function
|
||||
reynir marked this conversation as resolved
|
||||
let stream = Lwt_stream.return data in
|
||||
Git_kv.of_octets git_ctx ~remote stream >|= function
|
||||
| Ok git_kv -> Ok git_kv
|
||||
| Error `Msg msg ->
|
||||
Logs.err (fun m -> m "error restoring git state: %s" msg);
|
||||
|
|
Loading…
Reference in a new issue
It would be nice to also stream from cache - but I have not figured out a nice api for that in oneffs. The problem is the checksum is over the whole data, and we can't verify it until we've read it all. I'm not sure it's desirable to stream the whole data and then find out it's corrupt /o\