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(
14161416 }) |entry| {
14171417 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)) {
14201421 // Delete instead of including in hash calculation.
14211422 const fs_path = try arena.dupe(u8, entry.path);
14221423
......@@ -1454,7 +1455,7 @@ fn computeHash(
14541455 const hashed_file = try arena.create(HashedFile);
14551456 hashed_file.* = .{
14561457 .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),
14581459 .kind = kind,
14591460 .hash = undefined, // to be populated by the worker
14601461 .failure = undefined, // to be populated by the worker
......@@ -1657,9 +1658,9 @@ fn stripRoot(fs_path: []const u8, root_dir: []const u8) []const u8 {
16571658
16581659/// Make a file system path identical independently of operating system path inconsistencies.
16591660/// This converts backslashes into forward slashes.
1660fn normalizePathAlloc(arena: Allocator, fs_path: []const u8) ![]const u8 {
1661 if (fs.path.sep == canonical_sep) return fs_path;
1662 const normalized = try arena.dupe(u8, fs_path);
1661fn normalizePathAlloc(arena: Allocator, pkg_path: []const u8) ![]const u8 {
1662 const normalized = try arena.dupe(u8, pkg_path);
1663 if (fs.path.sep == canonical_sep) return normalized;
16631664 normalizePath(normalized);
16641665 return normalized;
16651666}