authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-04 19:12:57+02:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-09 15:00:22+02:00
log5f0b434f9031179609c97676bb43425f8710ac95
tree8b47befd714c8c9b81101dbcd0ff59a473d0782b
parent22e9c50376b8d7f2c67e3727bc40c697942576c8

fetch: remove root_dir from error messages

To be consistent with paths in manifest.

1 files changed, 7 insertions(+), 5 deletions(-)

src/Package/Fetch.zig+7-5
...@@ -1861,6 +1861,8 @@ const UnpackResult = struct {...@@ -1861,6 +1861,8 @@ const UnpackResult = struct {
1861 if (self.errors.items.len == 0 and self.root_error_message.len == 0)1861 if (self.errors.items.len == 0 and self.root_error_message.len == 0)
1862 return;1862 return;
18631863
1864 const root_dir = if (self.root_dir) |root_dir| root_dir else "";
1865
1864 const notes_len: u32 = @intCast(self.errors.items.len);1866 const notes_len: u32 = @intCast(self.errors.items.len);
1865 try eb.addRootErrorMessage(.{1867 try eb.addRootErrorMessage(.{
1866 .msg = try eb.addString(self.root_error_message),1868 .msg = try eb.addString(self.root_error_message),
...@@ -1873,21 +1875,21 @@ const UnpackResult = struct {...@@ -1873,21 +1875,21 @@ const UnpackResult = struct {
1873 .unable_to_create_sym_link => |info| {1875 .unable_to_create_sym_link => |info| {
1874 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{1876 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
1875 .msg = try eb.printString("unable to create symlink from '{s}' to '{s}': {s}", .{1877 .msg = try eb.printString("unable to create symlink from '{s}' to '{s}': {s}", .{
1876 info.file_name, info.link_name, @errorName(info.code),1878 stripRoot(info.file_name, root_dir), info.link_name, @errorName(info.code),
1877 }),1879 }),
1878 }));1880 }));
1879 },1881 },
1880 .unable_to_create_file => |info| {1882 .unable_to_create_file => |info| {
1881 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{1883 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
1882 .msg = try eb.printString("unable to create file '{s}': {s}", .{1884 .msg = try eb.printString("unable to create file '{s}': {s}", .{
1883 info.file_name, @errorName(info.code),1885 stripRoot(info.file_name, root_dir), @errorName(info.code),
1884 }),1886 }),
1885 }));1887 }));
1886 },1888 },
1887 .unsupported_file_type => |info| {1889 .unsupported_file_type => |info| {
1888 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{1890 eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{
1889 .msg = try eb.printString("file '{s}' has unsupported type '{c}'", .{1891 .msg = try eb.printString("file '{s}' has unsupported type '{c}'", .{
1890 info.file_name, info.file_type,1892 stripRoot(info.file_name, root_dir), info.file_type,
1891 }),1893 }),
1892 }));1894 }));
1893 },1895 },
...@@ -1914,8 +1916,8 @@ test "tarball with duplicate file names" {...@@ -1914,8 +1916,8 @@ test "tarball with duplicate file names" {
19141916
1915 try fb.expectFetchErrors(2,1917 try fb.expectFetchErrors(2,
1916 \\error: unable to unpack tarball1918 \\error: unable to unpack tarball
1917 \\ note: unable to create file 'package.tar/dir/file': PathAlreadyExists1919 \\ note: unable to create file 'dir/file': PathAlreadyExists
1918 \\ note: unable to create file 'package.tar/dir1/file1': PathAlreadyExists1920 \\ note: unable to create file 'dir1/file1': PathAlreadyExists
1919 \\1921 \\
1920 );1922 );
1921}1923}