| ... | ... | @@ -1047,10 +1047,6 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re |
| 1047 | 1047 | )); |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | | /// A `null` return value indicates the `tmp_directory` is populated directly |
| 1051 | | /// with the package contents. |
| 1052 | | /// A non-null return value means that the package contents are inside a |
| 1053 | | /// sub-directory indicated by the named path. |
| 1054 | 1050 | fn unpackResource( |
| 1055 | 1051 | f: *Fetch, |
| 1056 | 1052 | resource: *Resource, |
| ... | ... | @@ -1751,6 +1747,9 @@ const UnpackResult = struct { |
| 1751 | 1747 | allocator: std.mem.Allocator, |
| 1752 | 1748 | errors: std.ArrayListUnmanaged(Error) = .{}, |
| 1753 | 1749 | root_error_message: []const u8 = "", |
| 1750 | |
| 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. |
| 1754 | 1753 | root_dir: ?[]const u8 = null, |
| 1755 | 1754 | |
| 1756 | 1755 | const Error = union(enum) { |
| ... | ... | @@ -1774,7 +1773,6 @@ const UnpackResult = struct { |
| 1774 | 1773 | .unable_to_create_sym_link => |info| info.file_name, |
| 1775 | 1774 | .unsupported_file_type => |info| info.file_name, |
| 1776 | 1775 | }; |
| 1777 | | |
| 1778 | 1776 | return !filter.includePath(stripRoot(file_name, root_dir)); |
| 1779 | 1777 | } |
| 1780 | 1778 | |
| ... | ... | @@ -1916,8 +1914,8 @@ test "tarball with duplicate file names" { |
| 1916 | 1914 | |
| 1917 | 1915 | try fb.expectFetchErrors(2, |
| 1918 | 1916 | \\error: unable to unpack tarball |
| 1919 | | \\ note: unable to create file 'dir/file': PathAlreadyExists |
| 1920 | | \\ note: unable to create file 'dir1/file1': PathAlreadyExists |
| 1917 | \\ note: unable to create file 'package.tar/dir/file': PathAlreadyExists |
| 1918 | \\ note: unable to create file 'package.tar/dir1/file1': PathAlreadyExists |
| 1921 | 1919 | \\ |
| 1922 | 1920 | ); |
| 1923 | 1921 | } |
| ... | ... | @@ -2035,7 +2033,6 @@ const TestFetchBuilder = struct { |
| 2035 | 2033 | defer walker.deinit(); |
| 2036 | 2034 | while (try walker.next()) |entry| { |
| 2037 | 2035 | if (entry.kind != .file) continue; |
| 2038 | | // std.debug.print("{s}\n", .{entry.path}); |
| 2039 | 2036 | const path = try std.testing.allocator.dupe(u8, entry.path); |
| 2040 | 2037 | errdefer std.testing.allocator.free(path); |
| 2041 | 2038 | std.mem.replaceScalar(u8, path, std.fs.path.sep, '/'); |
| ... | ... | @@ -2082,6 +2079,16 @@ fn createTestTarball(dir: fs.Dir, tarball_name: []const u8, with_manifest: bool) |
| 2082 | 2079 | const TarHeader = std.tar.output.Header; |
| 2083 | 2080 | const prefix = tarball_name; |
| 2084 | 2081 | |
| 2082 | // add root directory |
| 2083 | { |
| 2084 | var hdr = TarHeader.init(); |
| 2085 | hdr.typeflag = .directory; |
| 2086 | try hdr.setPath(prefix, ""); |
| 2087 | try hdr.updateChecksum(); |
| 2088 | try file.writeAll(std.mem.asBytes(&hdr)); |
| 2089 | } |
| 2090 | |
| 2091 | // add files |
| 2085 | 2092 | const files: []const []const u8 = &.{ |
| 2086 | 2093 | "build.zig", |
| 2087 | 2094 | "src/main.zig", |
| ... | ... | @@ -2091,6 +2098,7 @@ fn createTestTarball(dir: fs.Dir, tarball_name: []const u8, with_manifest: bool) |
| 2091 | 2098 | "dir/file", |
| 2092 | 2099 | "dir1/file1", |
| 2093 | 2100 | }; |
| 2101 | |
| 2094 | 2102 | for (files) |path| { |
| 2095 | 2103 | var hdr = TarHeader.init(); |
| 2096 | 2104 | hdr.typeflag = .regular; |
| ... | ... | @@ -2099,6 +2107,7 @@ fn createTestTarball(dir: fs.Dir, tarball_name: []const u8, with_manifest: bool) |
| 2099 | 2107 | try file.writeAll(std.mem.asBytes(&hdr)); |
| 2100 | 2108 | } |
| 2101 | 2109 | |
| 2110 | // add manifest |
| 2102 | 2111 | if (with_manifest) { |
| 2103 | 2112 | const build_zig_zon = |
| 2104 | 2113 | \\ .{ |