Skip to content

Commit

Permalink
fix annoying bug re \n getting inserted.
Browse files Browse the repository at this point in the history
  • Loading branch information
akama committed Mar 12, 2021
1 parent f4f3269 commit 2d9f74c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion agent/agent.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ module File_transfer = struct
| #Cohttp.Code.success_status ->
let* f = Lwt_io.open_file ~mode:Output cmd.dst in
let body = Cohttp_lwt.Body.to_stream rbody in
let* () = Lwt_io.write_lines f body in
let safe_write_lines oc lines = Lwt_stream.iter_s (fun line -> Lwt_io.write oc line) lines in

This comment has been minimized.

Copy link
@hcarty

hcarty Mar 15, 2021

Contributor

Naming-wise, probably best to break from write_lines here because there's no sense of "lines" in this case. It's a stream of bytes with no implied delimiter between stream elements.

Maybe write_all or write_stream?

let* () = safe_write_lines f body in
let* () = Lwt_io.close f in
let () = out_push (Some "Download successful.\n") in
Lwt.return true
Expand Down

0 comments on commit 2d9f74c

Please sign in to comment.