authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-04 01:59:15+02:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-04-04 01:59:15+02:00
loga60b7af2c19ca14609bd052916299ffb64063856
tree54eb6ff054d660c6304f9eb1aa94ac64b67a25a5
parent8545cb014795b4137d1ad92c62d08014723abf9f

fetch: fix manifest included paths filtering

Filter should be applied on path where package root folder (if there is any) is stripped. Manifest is inside package root and has paths relative to package root not temporary directory root.

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

src/Package/Fetch.zig+6-5
...@@ -1416,7 +1416,8 @@ fn computeHash(...@@ -1416,7 +1416,8 @@ fn computeHash(
1416 }) |entry| {1416 }) |entry| {
1417 if (entry.kind == .directory) continue;1417 if (entry.kind == .directory) continue;
14181418
1419 if (!filter.includePath(entry.path)) {1419 const entry_pkg_path = stripRoot(entry.path, pkg_path.sub_path);
1420 if (!filter.includePath(entry_pkg_path)) {
1420 // Delete instead of including in hash calculation.1421 // Delete instead of including in hash calculation.
1421 const fs_path = try arena.dupe(u8, entry.path);1422 const fs_path = try arena.dupe(u8, entry.path);
14221423
...@@ -1454,7 +1455,7 @@ fn computeHash(...@@ -1454,7 +1455,7 @@ fn computeHash(
1454 const hashed_file = try arena.create(HashedFile);1455 const hashed_file = try arena.create(HashedFile);
1455 hashed_file.* = .{1456 hashed_file.* = .{
1456 .fs_path = fs_path,1457 .fs_path = fs_path,
1457 .normalized_path = try normalizePathAlloc(arena, stripRoot(fs_path, pkg_path.sub_path)),1458 .normalized_path = try normalizePathAlloc(arena, entry_pkg_path),
1458 .kind = kind,1459 .kind = kind,
1459 .hash = undefined, // to be populated by the worker1460 .hash = undefined, // to be populated by the worker
1460 .failure = undefined, // to be populated by the worker1461 .failure = undefined, // to be populated by the worker
...@@ -1657,9 +1658,9 @@ fn stripRoot(fs_path: []const u8, root_dir: []const u8) []const u8 {...@@ -1657,9 +1658,9 @@ fn stripRoot(fs_path: []const u8, root_dir: []const u8) []const u8 {
16571658
1658/// Make a file system path identical independently of operating system path inconsistencies.1659/// Make a file system path identical independently of operating system path inconsistencies.
1659/// This converts backslashes into forward slashes.1660/// This converts backslashes into forward slashes.
1660fn normalizePathAlloc(arena: Allocator, fs_path: []const u8) ![]const u8 {1661fn normalizePathAlloc(arena: Allocator, pkg_path: []const u8) ![]const u8 {
1661 if (fs.path.sep == canonical_sep) return fs_path;1662 const normalized = try arena.dupe(u8, pkg_path);
1662 const normalized = try arena.dupe(u8, fs_path);1663 if (fs.path.sep == canonical_sep) return normalized;
1663 normalizePath(normalized);1664 normalizePath(normalized);
1664 return normalized;1665 return normalized;
1665}1666}