aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Anić <igor.anic@gmail.com>2024-04-04 21:39:13 +0200
committerIgor Anić <igor.anic@gmail.com>2024-04-09 15:00:22 +0200
commit8c58b8fe0107fe3e06ec8bac2b2c25f706406c82 (patch)
tree0b935e778f0141f5c40f2156f1b093cd3ceb6932 /src
parentb422e4a202f3b4d6e33c1433c3d27152dc5bc925 (diff)
downloadzig-8c58b8fe0107fe3e06ec8bac2b2c25f706406c82.tar.gz
zig-8c58b8fe0107fe3e06ec8bac2b2c25f706406c82.zip
fetch: refactor package root in errors
Use stripRoot in less places. Strip it while copying error from diagnostic to unpack result so other palaces can be free of this logic.
Diffstat (limited to 'src')
-rw-r--r--src/Package/Fetch.zig18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig
index a393c7835e..9e91c0e029 100644
--- a/src/Package/Fetch.zig
+++ b/src/Package/Fetch.zig
@@ -1189,9 +1189,9 @@ fn unpackTarball(f: *Fetch, out_dir: fs.Dir, reader: anytype) RunError!UnpackRes
try res.rootErrorMessage("unable to unpack tarball");
for (diagnostics.errors.items) |item| {
switch (item) {
- .unable_to_create_file => |i| try res.unableToCreateFile(i.file_name, i.code),
- .unable_to_create_sym_link => |i| try res.unableToCreateSymLink(i.file_name, i.link_name, i.code),
- .unsupported_file_type => |i| try res.unsupportedFileType(i.file_name, @intFromEnum(i.file_type)),
+ .unable_to_create_file => |i| try res.unableToCreateFile(stripRoot(i.file_name, res.root_dir), i.code),
+ .unable_to_create_sym_link => |i| try res.unableToCreateSymLink(stripRoot(i.file_name, res.root_dir), i.link_name, i.code),
+ .unsupported_file_type => |i| try res.unsupportedFileType(stripRoot(i.file_name, res.root_dir), @intFromEnum(i.file_type)),
}
}
}
@@ -1764,13 +1764,13 @@ const UnpackResult = struct {
file_type: u8,
},
- fn excluded(self: Error, filter: Filter, root_dir: []const u8) bool {
+ fn excluded(self: Error, filter: Filter) bool {
const file_name = switch (self) {
.unable_to_create_file => |info| info.file_name,
.unable_to_create_sym_link => |info| info.file_name,
.unsupported_file_type => |info| info.file_name,
};
- return !filter.includePath(stripRoot(file_name, root_dir));
+ return !filter.includePath(file_name);
}
fn free(self: Error, allocator: std.mem.Allocator) void {
@@ -1835,7 +1835,7 @@ const UnpackResult = struct {
while (i > 0) {
i -= 1;
const item = self.errors.items[i];
- if (item.excluded(filter, self.root_dir)) {
+ if (item.excluded(filter)) {
_ = self.errors.swapRemove(i);
item.free(self.allocator);
}
@@ -1867,21 +1867,21 @@ const UnpackResult = struct {
.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}", .{
- stripRoot(info.file_name, self.root_dir), info.link_name, @errorName(info.code),
+ 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}", .{
- stripRoot(info.file_name, self.root_dir), @errorName(info.code),
+ 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}'", .{
- stripRoot(info.file_name, self.root_dir), info.file_type,
+ info.file_name, info.file_type,
}),
}));
},