Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Remove unconditional extention-check in library code #278

Closed
fahman opened this issue Jan 25, 2021 · 1 comment
Closed

Remove unconditional extention-check in library code #278

fahman opened this issue Jan 25, 2021 · 1 comment

Comments

@fahman
Copy link

fahman commented Jan 25, 2021

What would you like to have changed?

In all of the implementations of Archiver a hard-coded CheckExt is being invoked within Archive func. I propose removing this check from Archive and Unarchive and instead move it to the code that e.g. determines Archiver to be used. The operations of specific Archiver should not do any extension checking.

Why is this feature a useful, necessary, and/or important addition to this project?

When using archiver as library there are plenty of scenarios (e.g. temp files, in-memory files being compressed before transfer as a payload, number of well-known file names that internally are just archives, etc.) when file extension is just irrelevant. When selecting archiver implementation e.g. by archiver.DefaultTar the decision about format is already carried out so checking for extension within funcs of selected implementation seems to be redundant.

What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

Current hack is to always create a temp file with the required extension and copy stuff back and forth, which causes boiler-plate code and additional ways to break code.

Please link to any relevant issues, pull requests, or other discussions.

Similar request here: #255

@mholt
Copy link
Owner

mholt commented Jan 2, 2022

It's your lucky day, #302 does this. I completely redesigned this package and its core APIs don't rely on the file extension anymore (except for an optional Identify() function that can optionally use the file extension -- or the stream contents directly -- to match formats). That PR will become the basis for v4. Please try it out!

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

No branches or pull requests

2 participants