You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Or maybe it is not expected to use Tar.read and only Tar.really_read shoud be used ?
I tried to get a minimal failing script. The following program gives me this output. read_rec is calling reccursively Tar.read until n bytes have been read. I guess it should have the same behaviour with Tar.really_read
read_really tar...
file:test len:8
ok
read_rec tar...
file:test len:8
ok
read_really targz...
file:test len:8
ok
read_rec targz...
error: Unexpected end of file
(* bash : echo content > test tar -cf test.tar test tar -czf test.tar.gz test*)letdecompress()=let ( let* ) =Tar.( let* ) inletprint_err=function|Ok() -> Format.printf "ok\n"|Error`Eof -> Format.printf "error: end of file\n"|Error (`Gz msg) -> Format.printf "error: gz %s\n" msg
|Error (#Tar_unix.erroraserr) ->
Format.printf "error: %a\n"Tar_unix.pp_error err
inletfoldf?global:_ (header : Tar.Header.t) () =let* content = f (Int64.to_int header.file_size) inFormat.printf "file:%s len:%d\n" header.file_name (String.length content);
Tar.return (Ok())
in(* this function is failing for untargz *)letrec read_recacc=function|0 -> Tar.return (Ok acc)
|n ->
let* content =Tar.read n in
read_rec (acc ^ content) (n -String.length content)
in(* this one is ok *)letread_reallyn=Tar.really_read n inlet unzip =Tar_gz.in_gzipped inFormat.printf "read_really tar...\n";
(* we don’t care to close fd for this test *)let tar =Unix.openfile "test.tar" [ O_RDONLY ] 0inlet t =Tar.fold (fold read_really) ()inlet result =Tar_unix.run t tar in
print_err result;
Format.printf "read_rec tar...\n";
let t =Tar.fold (fold (read_rec "")) ()inlet tar =Unix.openfile "test.tar" [ O_RDONLY ] 0inlet result =Tar_unix.run t tar in
print_err result;
Format.printf "read_really targz...\n";
let targz =Unix.openfile "test.tar.gz" [ O_RDONLY ] 0inlet t =Tar.fold (fold read_really) ()inlet result =Tar_unix.run (unzip t) targz in
print_err result;
(* it fails here *)Format.printf "read_rec targz...\n";
let targz =Unix.openfile "test.tar.gz" [ O_RDONLY ] 0inlet t =Tar.fold (fold (read_rec "")) ()inlet result =Tar_unix.run (unzip t) targz in
print_err result;
()
The text was updated successfully, but these errors were encountered:
So your example works on my side. I hope it works for you. I will merge #161 and cut a release. Thanks for your report - this issue will remains open until you decide to close it 👍.
Combining
Tar.read
withTar_gz.in_gzipped
is failing.I think this is because the "gzip buffer" is not being used.
Maybe there is a missing function
read_through_gz
here ?ocaml-tar/lib/tar_gz.ml
Line 116 in 4215ff0
Or maybe it is not expected to use
Tar.read
and onlyTar.really_read
shoud be used ?I tried to get a minimal failing script. The following program gives me this output.
read_rec
is calling reccursively Tar.read until n bytes have been read. I guess it should have the same behaviour with Tar.really_readThe text was updated successfully, but these errors were encountered: