| ... | ... | @@ -465,10 +465,7 @@ fn runResource( |
| 465 | 465 | var unpack_result = try unpackResource(f, resource, uri_path, tmp_directory); |
| 466 | 466 | defer unpack_result.deinit(); |
| 467 | 467 | |
| 468 | | var pkg_path: Cache.Path = .{ |
| 469 | | .root_dir = tmp_directory, |
| 470 | | .sub_path = if (unpack_result.root_dir) |root_dir| root_dir else "", |
| 471 | | }; |
| 468 | var pkg_path: Cache.Path = .{ .root_dir = tmp_directory, .sub_path = unpack_result.root_dir }; |
| 472 | 469 | |
| 473 | 470 | // Apply btrfs workaround if needed. Reopen tmp_directory. |
| 474 | 471 | if (native_os == .linux and f.job_queue.work_around_btrfs_bug) { |
| ... | ... | @@ -503,8 +500,8 @@ fn runResource( |
| 503 | 500 | // directory. |
| 504 | 501 | f.actual_hash = try computeHash(f, pkg_path, filter); |
| 505 | 502 | |
| 506 | | break :blk if (unpack_result.root_dir) |root_dir| |
| 507 | | try fs.path.join(arena, &.{ tmp_dir_sub_path, root_dir }) |
| 503 | break :blk if (unpack_result.root_dir.len > 0) |
| 504 | try fs.path.join(arena, &.{ tmp_dir_sub_path, unpack_result.root_dir }) |
| 508 | 505 | else |
| 509 | 506 | tmp_dir_sub_path; |
| 510 | 507 | }; |
| ... | ... | @@ -1185,8 +1182,8 @@ fn unpackTarball(f: *Fetch, out_dir: fs.Dir, reader: anytype) RunError!UnpackRes |
| 1185 | 1182 | )); |
| 1186 | 1183 | |
| 1187 | 1184 | var res = UnpackResult.init(gpa); |
| 1188 | | if (diagnostics.root_dir) |root_dir| { |
| 1189 | | res.root_dir = try gpa.dupe(u8, root_dir); |
| 1185 | if (diagnostics.root_dir.len > 0) { |
| 1186 | res.root_dir = try gpa.dupe(u8, diagnostics.root_dir); |
| 1190 | 1187 | } |
| 1191 | 1188 | if (diagnostics.errors.items.len > 0) { |
| 1192 | 1189 | try res.rootErrorMessage("unable to unpack tarball"); |
| ... | ... | @@ -1748,9 +1745,9 @@ const UnpackResult = struct { |
| 1748 | 1745 | errors: std.ArrayListUnmanaged(Error) = .{}, |
| 1749 | 1746 | root_error_message: []const u8 = "", |
| 1750 | 1747 | |
| 1751 | | // A `null` value indicates the `tmp_directory` is populated directly with the package contents. |
| 1752 | | // A non-null value means that the package contents are inside a sub-directory indicated by the named path. |
| 1753 | | root_dir: ?[]const u8 = null, |
| 1748 | // A non empty value means that the package contents are inside a |
| 1749 | // sub-directory indicated by the named path. |
| 1750 | root_dir: []const u8 = "", |
| 1754 | 1751 | |
| 1755 | 1752 | const Error = union(enum) { |
| 1756 | 1753 | unable_to_create_sym_link: struct { |
| ... | ... | @@ -1802,9 +1799,7 @@ const UnpackResult = struct { |
| 1802 | 1799 | } |
| 1803 | 1800 | self.errors.deinit(self.allocator); |
| 1804 | 1801 | self.allocator.free(self.root_error_message); |
| 1805 | | if (self.root_dir) |root_dir| { |
| 1806 | | self.allocator.free(root_dir); |
| 1807 | | } |
| 1802 | self.allocator.free(self.root_dir); |
| 1808 | 1803 | self.* = undefined; |
| 1809 | 1804 | } |
| 1810 | 1805 | |
| ... | ... | @@ -1837,11 +1832,10 @@ const UnpackResult = struct { |
| 1837 | 1832 | // Filter errors by manifest inclusion rules. |
| 1838 | 1833 | fn filterErrors(self: *UnpackResult, filter: Filter) !void { |
| 1839 | 1834 | var i = self.errors.items.len; |
| 1840 | | const root_dir: []const u8 = if (self.root_dir) |root_dir| root_dir else ""; |
| 1841 | 1835 | while (i > 0) { |
| 1842 | 1836 | i -= 1; |
| 1843 | 1837 | const item = self.errors.items[i]; |
| 1844 | | if (item.excluded(filter, root_dir)) { |
| 1838 | if (item.excluded(filter, self.root_dir)) { |
| 1845 | 1839 | _ = self.errors.swapRemove(i); |
| 1846 | 1840 | item.free(self.allocator); |
| 1847 | 1841 | } |
| ... | ... | @@ -1861,8 +1855,6 @@ const UnpackResult = struct { |
| 1861 | 1855 | if (self.errors.items.len == 0 and self.root_error_message.len == 0) |
| 1862 | 1856 | return; |
| 1863 | 1857 | |
| 1864 | | const root_dir = if (self.root_dir) |root_dir| root_dir else ""; |
| 1865 | | |
| 1866 | 1858 | const notes_len: u32 = @intCast(self.errors.items.len); |
| 1867 | 1859 | try eb.addRootErrorMessage(.{ |
| 1868 | 1860 | .msg = try eb.addString(self.root_error_message), |
| ... | ... | @@ -1875,21 +1867,21 @@ const UnpackResult = struct { |
| 1875 | 1867 | .unable_to_create_sym_link => |info| { |
| 1876 | 1868 | eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{ |
| 1877 | 1869 | .msg = try eb.printString("unable to create symlink from '{s}' to '{s}': {s}", .{ |
| 1878 | | stripRoot(info.file_name, root_dir), info.link_name, @errorName(info.code), |
| 1870 | stripRoot(info.file_name, self.root_dir), info.link_name, @errorName(info.code), |
| 1879 | 1871 | }), |
| 1880 | 1872 | })); |
| 1881 | 1873 | }, |
| 1882 | 1874 | .unable_to_create_file => |info| { |
| 1883 | 1875 | eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{ |
| 1884 | 1876 | .msg = try eb.printString("unable to create file '{s}': {s}", .{ |
| 1885 | | stripRoot(info.file_name, root_dir), @errorName(info.code), |
| 1877 | stripRoot(info.file_name, self.root_dir), @errorName(info.code), |
| 1886 | 1878 | }), |
| 1887 | 1879 | })); |
| 1888 | 1880 | }, |
| 1889 | 1881 | .unsupported_file_type => |info| { |
| 1890 | 1882 | eb.extra.items[note_i] = @intFromEnum(try eb.addErrorMessage(.{ |
| 1891 | 1883 | .msg = try eb.printString("file '{s}' has unsupported type '{c}'", .{ |
| 1892 | | stripRoot(info.file_name, root_dir), info.file_type, |
| 1884 | stripRoot(info.file_name, self.root_dir), info.file_type, |
| 1893 | 1885 | }), |
| 1894 | 1886 | })); |
| 1895 | 1887 | }, |