authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-06 22:16:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-08 16:54:31-07:00
log1ca442832465d9735313a326326fbe96a7ec55ed
treed6ce857cb17f42df1ebf48d1ab0b447817bd92ce
parentddb7c40037e2834c372a980a413c89b9b250988f

fix recursive package fetching logic

For path-relative dependencies, they always need to be added to the hash table at the end. For remote dependencies, they never need to be added.

1 files changed, 9 insertions(+), 3 deletions(-)

src/Package/Fetch.zig+9-3
......@@ -448,14 +448,20 @@ fn queueJobsForDeps(f: *Fetch, hash: Manifest.MultiHashHexDigest) RunError!void
448448 try f.job_queue.all_fetches.ensureUnusedCapacity(gpa, new_fetches.len);
449449 try f.job_queue.table.ensureUnusedCapacity(gpa, @intCast(new_fetches.len + 1));
450450
451 // It is impossible for there to be a collision here. Consider all three cases:
451 // There are four cases here:
452452 // * Correct hash is provided by manifest.
453 // - Redundant jobs are skipped in the loop below.
453 // - Hash map already has the entry, no need to add it again.
454454 // * Incorrect hash is provided by manifest.
455455 // - Hash mismatch error emitted; `queueJobsForDeps` is not called.
456456 // * Hash is not provided by manifest.
457457 // - Hash missing error emitted; `queueJobsForDeps` is not called.
458 f.job_queue.table.putAssumeCapacityNoClobber(hash, f);
458 // * path-based location is used without a hash.
459 // - We need to add `hash` to the table now.
460 switch (f.location) {
461 .remote => assert(f.job_queue.table.get(hash) == f),
462 .relative_path => f.job_queue.table.putAssumeCapacityNoClobber(hash, f),
463 .path_or_url => unreachable,
464 }
459465
460466 for (deps) |dep| {
461467 const new_fetch = &new_fetches[new_fetch_index];