Skip to content

std.tar: add strip components error to diagnostics #19615

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

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

ianic
Copy link
Contributor

@ianic ianic commented Apr 11, 2024

This was the only kind of error which was raised in pipeToFileSystem and not added to Diagnostics.
Shell tar silently ignores paths which are stripped out when used with --strip-components switch. This enables that same behavior, errors will be collected in diagnostics but caller is free to ignore that type of errors.
Enables use case where caller knows structure of the tar file and want to extract only some deeply nested folders ignoring upper files/folders.

Fixes: #17620 by giving caller options:

  • not provide diagnostic and get errors
  • provide diagnostics and analyze errors
  • provide diagnostics and ignore errors

@@ -1184,6 +1184,7 @@ fn unpackTarball(f: *Fetch, out_dir: fs.Dir, reader: anytype) RunError!UnpackRes
.unable_to_create_file => |i| res.unableToCreateFile(stripRoot(i.file_name, res.root_dir), i.code),
.unable_to_create_sym_link => |i| res.unableToCreateSymLink(stripRoot(i.file_name, res.root_dir), i.link_name, i.code),
.unsupported_file_type => |i| res.unsupportedFileType(stripRoot(i.file_name, res.root_dir), @intFromEnum(i.file_type)),
.components_outside_stripped_prefix => {}, // impossible with strip_components = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

If this cannot be reached (from how I understand the comment), it could/should be explicit unreachable, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right!

Was thinking about that but I somehow decide to go this way. But you are right we have keyword for marking unreachable code paths. Fixing it.
Thanks.

ianic added 2 commits July 3, 2024 12:12
This was the only kind of error which was raised in pipeToFileSystem and
not added to Diagnostics.
Shell tar silently ignores paths which are stripped out when used with
`--strip-components` switch. This enables that same behavior, errors
will be collected in diagnostics but caller is free to ignore that type
of diagnostics errors.
Enables use case where caller knows structure of the tar file and want
to extract only some deeply nested folders ignoring upper files/folders.

Fixes: ziglang#17620 by giving caller options:
- not provide diagnostic and get errors
- provide diagnostics and analyze errors
- provide diagnostics and ignore errors
@andrewrk andrewrk enabled auto-merge July 3, 2024 19:13
@andrewrk andrewrk merged commit 768b177 into ziglang:master Jul 4, 2024
10 checks passed
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.

std.tar single file tars fail.
3 participants