Skip to content

Commit 4fc295d

Browse files
castholmandrewrk
authored andcommitted
Take eagerness into account when deduplicating dependencies
If the same dependency is first found as lazy and then later as eager, the existing entry needs to be updated to eager in order for `b.dependency()` to work.
1 parent e5d9d3f commit 4fc295d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Package/Fetch.zig

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,9 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
662662
// * path-based location is used without a hash.
663663
// - Hash is added to the table based on the path alone before
664664
// calling run(); no need to add it again.
665+
//
666+
// If we add a dep as lazy and then later try to add the same dep as eager,
667+
// eagerness takes precedence and the existing entry is updated.
665668

666669
for (dep_names, deps) |dep_name, dep| {
667670
const new_fetch = &new_fetches[new_fetch_index];
@@ -673,7 +676,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
673676
const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len;
674677
const multihash_digest = h[0..digest_len].*;
675678
const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
676-
if (gop.found_existing) continue;
679+
if (gop.found_existing) {
680+
if (!dep.lazy) {
681+
gop.value_ptr.*.lazy_status = .eager;
682+
}
683+
continue;
684+
}
677685
gop.value_ptr.* = new_fetch;
678686
break :h multihash_digest;
679687
},
@@ -684,7 +692,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
684692
const new_root = try f.package_root.resolvePosix(parent_arena, rel_path);
685693
const multihash_digest = relativePathDigest(new_root, cache_root);
686694
const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
687-
if (gop.found_existing) continue;
695+
if (gop.found_existing) {
696+
if (!dep.lazy) {
697+
gop.value_ptr.*.lazy_status = .eager;
698+
}
699+
continue;
700+
}
688701
gop.value_ptr.* = new_fetch;
689702
break :l .{ .relative_path = new_root };
690703
},

0 commit comments

Comments
 (0)