rust-lang-nursery / rust-cookbook

https://rust-lang-nursery.github.io/rust-cookbook
Creative Commons Zero v1.0 Universal
2.24k stars 286 forks source link

Update tar-compress docs #698

Open schneems opened 1 month ago

schneems commented 1 month ago

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.