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

package fetching: elide errors from unpacking that relate to excluded file paths #17460

Closed
andrewrk opened this issue Oct 9, 2023 · 0 comments · Fixed by #19500
Closed

package fetching: elide errors from unpacking that relate to excluded file paths #17460

andrewrk opened this issue Oct 9, 2023 · 0 comments · Fixed by #19500
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Oct 9, 2023

Extracted from #17392.

If any of the file paths associated with these errors:

zig/src/Package/Fetch.zig

Lines 1080 to 1100 in f7bc55c

.unable_to_create_sym_link => |info| {
eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
.msg = try eb.printString("unable to create symlink from '{s}' to '{s}': {s}", .{
info.file_name, info.link_name, @errorName(info.code),
}),
}));
},
.unable_to_create_file => |info| {
eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
.msg = try eb.printString("unable to create file '{s}': {s}", .{
info.file_name, @errorName(info.code),
}),
}));
},
.unsupported_file_type => |info| {
eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
.msg = try eb.printString("file '{s}' has unsupported type '{c}'", .{
info.file_name, @intFromEnum(info.file_type),
}),
}));
},

would be excluded by this filter:

zig/src/Package/Fetch.zig

Lines 1500 to 1518 in f7bc55c

const Filter = struct {
include_paths: std.StringArrayHashMapUnmanaged(void) = .{},
/// sub_path is relative to the package root.
pub fn includePath(self: Filter, sub_path: []const u8) bool {
if (self.include_paths.count() == 0) return true;
if (self.include_paths.contains("")) return true;
if (self.include_paths.contains(sub_path)) return true;
// Check if any included paths are parent directories of sub_path.
var dirname = sub_path;
while (std.fs.path.dirname(dirname)) |next_dirname| {
if (self.include_paths.contains(sub_path)) return true;
dirname = next_dirname;
}
return false;
}
};

then don't report those errors.

Above, I linked to the code related to tarball unpacking, but the same needs to be done for the other kinds of unpacking too:

  • directory tree copying
  • fetching from git
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior enhancement Solving this issue will likely involve adding new logic or components to the codebase. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Oct 9, 2023
@andrewrk andrewrk added this to the 0.13.0 milestone Oct 9, 2023
@andrewrk andrewrk modified the milestones: 0.13.0, 0.12.0 Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant