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

Update tar-compress docs #698

Merged

Conversation

schneems
Copy link
Contributor

@schneems schneems commented Jun 6, 2024

  • Call finish to finalize the archive recommended by tar.
  • Show an example of adding an archive without renaming it.
  • Callout differences between tar::Builder defaults and tar(1) defaults

Context

On seeing these docs I was unsure if there was another, better way, to add all the contents of one directory into an archive. After researching, I see people use this function by calling it with an empty string. I feel this is a common operation and would like to see it spelled out in the documentation.

In addition, I hit an edge case where tar(1) produced significantly smaller files than the tar crate, reproduction: https://github.com/schneems/tar_comparison/blob/bfd420a012b46e80435cf4e7c67ca1661357fde3/README.md. It turns out that the problem was that the directory contained symlinks to other files in the same directory. The follow_symlinks(true) behavior is on by default and is the opposite of the tar(1) default. It caused the program to duplicate the same file multiple times which significantly increased the archive size. I believe someone looking for "How to Compress a directory into tarball" is likely looking to replicate tar czf behavior and would like to know the main differences.

- Call finish to finalize the archive [recommended by tar](https://docs.rs/tar/0.4.41/tar/struct.Builder.html#method.append_dir_all).
- Show an example of adding an archive **without** renaming it.
- Callout differences between `tar::Builder` defaults and `tar(1)` defaults

## Context

On seeing these docs I was unsure if there was another, better way, to add all the contents of one directory into an archive. After researching, I see people use this function by call it with an empty string. I feel this is a common operation and would like to see it spelled out in the documentation.

In addition, I hit an edge case where `tar(1)` produced significantly smaller files than the `tar` crate, reproduction: https://github.com/schneems/tar_comparison/blob/bfd420a012b46e80435cf4e7c67ca1661357fde3/README.md. It turns out that the problem was that the directory contained symlinks to other files in the same directory. The `follow_symlinks(true)` behavior is on by default and is the opposite of the `tar(1)` default. It caused the program to duplicate the same file multiple times which significantly increased the archive size. I believe someone looking for "How to  Compress a directory into tarball" is likely looking to replicate `tar czf` behavior and would like to know the main differences.
@schneems schneems marked this pull request as ready for review June 6, 2024 22:15
Copy link
Collaborator

@AndyGauge AndyGauge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the easy recipe addition, it actually is more useful

@AndyGauge AndyGauge merged commit c3776f5 into rust-lang-nursery:master Nov 28, 2024
@schneems
Copy link
Contributor Author

Thanks!

@AndyGauge
Copy link
Collaborator

AndyGauge commented Nov 29, 2024

oh hey I remember meeting you outside rubyconf picking up my badge. Appreciate the help.

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

Successfully merging this pull request may close these issues.

2 participants