Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add doc hint that default is different than
tar
(#366)
The default of `tar` is to include a symlink in the archive. The default of `tar::Builder` is to resolve symlinks and replace them with the resulting file. This commit helps to clarify that difference by highlighting that `follow_symlinks(true)` provides the same behavior as `tar -h`. ## Context This caused me much head-scratching in a problem where calling `tar` resulted in much lower file sizes than what I thought was the comparable rust code. I created a reproduction as part of that debugging process (if you're interested) https://github.com/schneems/tar_comparison/blob/bfd420a012b46e80435cf4e7c67ca1661357fde3/README.md. It turns out this was the issue I was facing: ``` $ tar -tvzf system_tar_gzip_one_operation.tar.gz | grep libruby.so -rwxr-xr-x 0 rschneeman staff 12364984 Jun 5 16:13 lib/libruby.so.3.1.6 lrwxr-xr-x 0 rschneeman staff 0 Jun 5 16:14 lib/libruby.so.3.1 -> libruby.so.3.1.6 lrwxr-xr-x 0 rschneeman staff 0 Jun 5 16:14 lib/libruby.so -> libruby.so.3.1.6 $ tar -tvzf rust_tar_gzip_one_operation.tar.gz | grep libruby.so -rwxr-xr-x 0 501 20 12364984 Jun 5 16:13 lib/libruby.so.3.1.6 -rwxr-xr-x 0 501 20 12364984 Jun 5 16:13 lib/libruby.so.3.1 -rwxr-xr-x 0 501 20 12364984 Jun 5 16:13 lib/libruby.so ``` In the "system" archive produced by the `tar` cli there's one `so` binary and two symlinks to the same file. In the "rust" version (using `tar::Builder`) there are three copies of the same binary. I previously saw that option's documentation when I was debugging my issue but didn't fully internalize the implications. My hope is that by documenting what feature this is similar to in (system) `tar`, that the reader will make a connection that the two have different defaults.
- Loading branch information