Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Feb 17, 2024
1 parent a139c5e commit 17eefc7
Show file tree
Hide file tree
Showing 7 changed files with 568 additions and 546 deletions.
1 change: 1 addition & 0 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
bob.dns
bob.reporters
bob.extract
bob.generate
bob.happy-eyeballs))

(executable
Expand Down
21 changes: 12 additions & 9 deletions bin/send.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ let () = Sys.set_signal Sys.sigpipe Sys.Signal_ignore
the EPIPE error on the [write()] syscall. *)

let compress_with_reporter quiet ~compression ~config store hashes =
with_reporter ~config quiet (compression_progress ~total:(Pack.length store))
with_reporter ~config quiet
(compression_progress ~total:(Generate.length store))
@@ fun (reporter, finalise) ->
let open Fiber in
Logs.debug (fun m -> m "Start deltification.");
Pack.deltify ~reporter:(Fiber.return <.> reporter) ~compression store hashes
Generate.deltify
~reporter:(Fiber.return <.> reporter)
~compression store hashes
>>| fun res ->
Logs.debug (fun m -> m "Deltification is done.");
finalise ();
Expand All @@ -22,14 +25,14 @@ type pack = Stream of Stdbob.bigstring Stream.stream | File of Bob_fpath.t
let emit_with_reporter quiet ?g ?level ~config store
(objects : Digestif.SHA1.t Carton.Enc.q Stream.stream) =
with_reporter ~config quiet
(progress_bar_for_objects ~total:(Pack.length store))
(progress_bar_for_objects ~total:(Generate.length store))
@@ fun (reporter, finalise) ->
let open Fiber in
let open Stream in
let path = Temp.random_temporary_path ?g "pack-%s.pack" in
Logs.debug (fun m -> m "Generate the PACK file: %a" Bob_fpath.pp path);
let flow =
Pack.make ?level
Generate.make_from_store ?level
~reporter:(Fiber.return <.> reporter <.> Stdbob.always 1)
store
in
Expand All @@ -42,7 +45,7 @@ let emit_one_with_reporter quiet ?level ~config path =
with_reporter ~config quiet (progress_bar_for_file ~total)
@@ fun (reporter, finalise) ->
let open Fiber in
Pack.make_one ~len:Bob_unix.Crypto.max_packet ?level
Generate.make_from_file ~len:Bob_unix.Crypto.max_packet ?level
~reporter:(Fiber.return <.> reporter)
~finalise path
>>= function
Expand Down Expand Up @@ -70,10 +73,10 @@ let transfer_with_reporter quiet ~config ~identity ~ciphers ~shared_keys

let generate_pack_file quiet ~config ~g compression path =
let open Fiber in
Pack.store path >>= fun (hashes, store) ->
match Pack.length store with
| 0 -> assert false
| 1 ->
Generate.store path >>= fun (hashes, store) ->
match Generate.length store with
| 0 | 1 -> assert false
| 2 ->
emit_one_with_reporter quiet
~level:(if compression then 4 else 0)
~config path
Expand Down
6 changes: 6 additions & 0 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
(modules extract)
(libraries bob.reporters bob.protocol bob.pack))

(library
(name generate)
(public_name bob.generate)
(modules generate)
(libraries bob.reporters bob.protocol bob.pack))

(library
(name pack)
(public_name bob.pack)
Expand Down
Loading

0 comments on commit 17eefc7

Please sign in to comment.