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

fix: add tolerant tar extraction on windows to solve failing on symlinks #1138

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Krande
Copy link

@Krande Krande commented Oct 26, 2024

Hey guys,

this is supposed to close #940.

This is my first time writing rust beyond just "hello world", so any suggestions for improvements are most welcome!

@wolfv
Copy link
Member

wolfv commented Oct 26, 2024

Thank you! On first glance, looks good!

@Krande
Copy link
Author

Krande commented Oct 28, 2024

@wolfv i think I've fixed the linting issue. Let me know if there is anything else I should consider.

Copy link
Member

@wolfv wolfv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Excellent PR and I agree about being more lenient about symlinks on Windows.

I think the error handling is a bit too lenient now, though. There are definitely errors that are worth bailing out.

match file.header().entry_type() {
EntryType::Symlink if cfg!(target_os = "windows") => {
if let Err(e) = file.unpack(&path) {
println!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always use tracing::warn! or tracing::error!.

}
}
Err(e) => {
println!("Warning: failed to read an entry due to {:?}", e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case, we should also return the error and fail the operation.

}
_ => {
if let Err(e) = file.unpack(&path) {
println!("Warning: failed to unpack {:?} due to {:?}", path, e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again we should return the error here :)

@wolfv
Copy link
Member

wolfv commented Oct 29, 2024

Hi @Krande - let me know if you want to make the changes or if you would prefer me taking over :)

@Krande
Copy link
Author

Krande commented Oct 29, 2024

If you have time to implement the changes, feel free to finish them:) if not, I'll likely start to implement them after lunch time tomorrow!

@wolfv
Copy link
Member

wolfv commented Oct 29, 2024

I looked a little bit deeper and I think unfortunately this doesn't cover a bunch of (other) edge cases that the original tar extraction code covers. That's really unfortunate. Ideally we could implement this kind of behavior / filtering in tar-rs directly.

@Krande
Copy link
Author

Krande commented Oct 30, 2024

I see. I checked tar-rs and found this alexcrichton/tar-rs#280 which I guess is related.

@Krande
Copy link
Author

Krande commented Oct 30, 2024

Would it be possible to make this tolerant extraction feature optional by hiding it behind an opt-in flag until a better long-term solution can be found?

That way, it is at least possible for us forced to use windows in our day jobs to use rattler-build for projects containing symlinks :)

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

Successfully merging this pull request may close these issues.

Failed to extract archive on windows
2 participants