Open ClementNerma opened 1 year ago
I saw that the destination file was correctly being created and filled with 4096 bytes of data, then the error appears.
Maybe there's some problem with the system you are running this on? Perhaps it runs out of the space? Or the admin has set an artifical limit?
No as I'm able to extract the tarball with the tar
command.
I tried to copy the Entry
's content to a buffer directly, and saw that zero bytes had been copied.
So that's not a filesystem issue at all, even in memory the problem appears. And the 4096 allocated bytes on disk seem to be when the file was created, before any data was actually written to it.
Ok so after a bit more testing it seems like the problem comes from the fact I iter over all .entries()
values and store them in a Vec. From then, when I try to unpack one entry (even the first one), it fails for whatever reason.
If I don't store these entries in a vec and instead directly extract them one by one it works perfectly fine.
What could be causing this behaviour?
That's because tar is a streaming format.
When you iterate over them, tar::Archive
calls the underlying Reader
which implements Read
to read the data, which changes the cursor.
I see! I feel like this isn't explicited enough in the documentation, I didn't understand that at all. Maybe this could added in the docs of Entries
and/or Entry
to avoid other peoples such problems :) ?
I see! I feel like this isn't explicited enough in the documentation, I didn't understand that at all. Maybe this could added in the docs of
Entries
and/orEntry
to avoid other peoples such problems :) ?
That will certainly help.
I remember similar things happen in zip-rs/zip where Entries
of zip are stored.
Since they both refers to the same underlying File
, using one invalidates others.
I keep getting
failed to write entire file
errors when calling the.unpack()
and.unpack_in()
methods fromEntry
.I saw that the destination file was correctly being created and filled with 4096 bytes of data, then the error appears.
I have no idea why this happens - could you please enlighten me?
Thanks in advance for your help!