otp icon indicating copy to clipboard operation
otp copied to clipboard

Fix erl_tar compatibility with compressed archives

Open dotsimon opened this issue 3 years ago • 3 comments

In OTP 24, erl_tar cannot read compressed tar files that have zero padding after the compressed data. Examples of such tar files are those from tapes (yes, even in 2022) or created by bsdtar Prior to commit e95f648 this data was correctly handled at least for binaries.

This commit introduces a new option to file:open Modes to handle this case: compressed_one

dotsimon avatar Oct 03 '22 18:10 dotsimon

CT Test Results

       3 files     139 suites   1h 29m 23s :stopwatch: 2 912 tests 2 733 :heavy_check_mark: 178 :zzz: 1 :x: 3 379 runs  3 167 :heavy_check_mark: 211 :zzz: 1 :x:

For more details on these failures, see this check.

Results for commit a5892472.

:recycle: This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

github-actions[bot] avatar Oct 03 '22 18:10 github-actions[bot]

Pretty sure dialyzer is wrong about that. And also that the test failures (peer and global) are problems with the tests and not this PR.

dotsimon avatar Oct 13 '22 21:10 dotsimon

the test failures (peer and global) are problems with the tests and not this PR.

Yes.

Pretty sure dialyzer is wrong about that.

Running the test with cover, I notice that true clause in lines 366-367 are never executed.

Looking further, I see that the Opts variable originates from a call to open_mode/2. According to typer, the spec is:

-spec open_mode(maybe_improper_list()) ->
    {'error','einval'} | {'ok','false' | 'read' | 'write',['raw'],['compressed' | 'read_ahead']}.

Opts comes from the last element in the ok tuple, which is:

['compressed' | 'read_ahead']

Please add a test case to verify that your fix fixes the bug.

bjorng avatar Oct 14 '22 07:10 bjorng

I added a test case and fixed the conditional. Thanks for your comments.

dotsimon avatar Oct 18 '22 05:10 dotsimon

Thanks! Added to our daily builds.

bjorng avatar Oct 18 '22 11:10 bjorng

Thanks!

bjorng avatar Oct 20 '22 11:10 bjorng