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

Rename function not called for compression-only formats #31

Open
simeonmiteff opened this issue Oct 22, 2024 · 0 comments
Open

Rename function not called for compression-only formats #31

simeonmiteff opened this issue Oct 22, 2024 · 0 comments

Comments

@simeonmiteff
Copy link

Calling Extractor's Archive() function is convenient due to the format auto-detection (allowing the calling application to treat files as generic archives and have this module figured out the details) however, the behaviour of the function is different depending on the file type.

In particular with compression-only formats don't call the rename function, and the location parameter has to be a file path (vs. a directory path). It would be very handy to make the use of Archive() as consistent as possible. One way may be to add the call to the rename function to the compression-only format functions (e.g. func (e *Extractor) Gz/Bz2/etc...):

if rename != nil {
    location = rename(location)
}

This gives the caller an opportunity to detect the compression case in the rename function (comparing the old name to location provided to the Archive() call) and provide a destination path for the uncompressed file.

I admit this proposal isn't super elegant. It may be worth checking if existing public dependents are calling Archive() for compression-only formats and providing a non-nil renamer. If not, then it the proposal probably wouldn't break anything. I would also be happy to co-design a new API to make this use case less complicated.

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

No branches or pull requests

1 participant