Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work correctly when entries are collected into a Vec #344

Open
KSXGitHub opened this issue Nov 5, 2023 · 2 comments
Open

Doesn't work correctly when entries are collected into a Vec #344

KSXGitHub opened this issue Nov 5, 2023 · 2 comments

Comments

@KSXGitHub
Copy link

Steps to reproduce

  1. Clone this repo: https://github.com/KSXGitHub/tar-rs-bug-collect-entries-343
  2. Run reproduce.bash

Expected behavior

It prints the content of the files correctly.

Actual behavior

It prints empty strings as content.

@ChewingBever
Copy link

Note that care must be taken to consider each entry within an archive in sequence. If entries are processed out of sequence (from what the iterator returns), then the contents read for each entry may be corrupted.

As the docs state in the description of the entries function, you cannot process the entries out of order., which is what you are doing. You have to process the entries one by one from what the iterator returns.

This isn't a bug, it's expected behavior.

@namse
Copy link

namse commented Dec 11, 2023

In my case, tar always read file's content as empty.

For example, when I save the content as Hello, but it shows '\0\0\0\0\0'.

assertion `left == right` failed
  left: "\0\0\0\0\0"
 right: "Hello"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

So I guess it's not a problem to use collect, but I think there are some problem with in-memory source?

-- edited

Nevermind my case, it become ok when I use for-loop instead of collect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants