Merge pull request 'when creating the tarball, only include the packages folder, repo and version' (#30) from tar-include-only-packages-version-repo into main

Reviewed-on: #30
Reviewed-by: Reynir Björnsson <reynir@reynir.dk>
This commit is contained in:
Reynir Björnsson 2024-11-28 09:12:34 +00:00
commit ddb0f610e4

View file

@ -640,6 +640,13 @@ module Make
let entries_of_git ~mtime store repo urls = let entries_of_git ~mtime store repo urls =
let entries = Git.contents store in let entries = Git.contents store in
let to_entry path = let to_entry path =
match Mirage_kv.Key.segments path with
(* from opam source code, src/repository/opamHTTP.ml:
include only three top-level dirs/files: packages, version, repo *)
| "packages" :: _
| "version" :: _
| "repo" :: _ ->
begin
Store.get store path >|= function Store.get store path >|= function
| Ok data -> | Ok data ->
let data = let data =
@ -655,7 +662,10 @@ module Make
(Mirage_kv.Key.to_string path) (Int64.of_int size) in (Mirage_kv.Key.to_string path) (Int64.of_int size) in
urls := Git.find_urls !urls path data; urls := Git.find_urls !urls path data;
Some (Some Tar.Header.Ustar, hdr, once data) Some (Some Tar.Header.Ustar, hdr, once data)
| Error _ -> None in | Error _ -> None
end
| _ -> Lwt.return None
in
let entries = Lwt_stream.filter_map_s to_entry entries in let entries = Lwt_stream.filter_map_s to_entry entries in
Lwt.return begin fun () -> Tar.High (High.inj (Lwt_stream.get entries >|= Result.ok)) end Lwt.return begin fun () -> Tar.High (High.inj (Lwt_stream.get entries >|= Result.ok)) end