| ... | ... | @@ -734,28 +734,34 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 734 | 734 | // calling run(); no need to add it again. |
| 735 | 735 | // |
| 736 | 736 | // If we add a dep as lazy and then later try to add the same dep as eager, |
| 737 | | // eagerness takes precedence and the existing entry is updated. |
| 737 | // eagerness takes precedence and the existing entry is updated and re-scheduled |
| 738 | // for fetching. |
| 738 | 739 | |
| 739 | 740 | for (dep_names, deps) |dep_name, dep| { |
| 741 | var promoted_existing_to_eager = false; |
| 740 | 742 | const new_fetch = &new_fetches[new_fetch_index]; |
| 741 | 743 | const location: Location = switch (dep.location) { |
| 742 | | .url => |url| .{ .remote = .{ |
| 743 | | .url = url, |
| 744 | | .hash = h: { |
| 745 | | const h = dep.hash orelse break :h null; |
| 746 | | const pkg_hash: Package.Hash = .fromSlice(h); |
| 747 | | if (h.len == 0) break :h pkg_hash; |
| 748 | | const gop = f.job_queue.table.getOrPutAssumeCapacity(pkg_hash); |
| 749 | | if (gop.found_existing) { |
| 750 | | if (!dep.lazy) { |
| 751 | | gop.value_ptr.*.lazy_status = .eager; |
| 744 | .url => |url| .{ |
| 745 | .remote = .{ |
| 746 | .url = url, |
| 747 | .hash = h: { |
| 748 | const h = dep.hash orelse break :h null; |
| 749 | const pkg_hash: Package.Hash = .fromSlice(h); |
| 750 | if (h.len == 0) break :h pkg_hash; |
| 751 | const gop = f.job_queue.table.getOrPutAssumeCapacity(pkg_hash); |
| 752 | if (gop.found_existing) { |
| 753 | if (!dep.lazy and gop.value_ptr.*.lazy_status != .eager) { |
| 754 | gop.value_ptr.*.lazy_status = .eager; |
| 755 | promoted_existing_to_eager = true; |
| 756 | } else { |
| 757 | continue; |
| 758 | } |
| 752 | 759 | } |
| 753 | | continue; |
| 754 | | } |
| 755 | | gop.value_ptr.* = new_fetch; |
| 756 | | break :h pkg_hash; |
| 760 | gop.value_ptr.* = new_fetch; |
| 761 | break :h pkg_hash; |
| 762 | }, |
| 757 | 763 | }, |
| 758 | | } }, |
| 764 | }, |
| 759 | 765 | .path => |rel_path| l: { |
| 760 | 766 | // This might produce an invalid path, which is checked for |
| 761 | 767 | // at the beginning of run(). |
| ... | ... | @@ -763,10 +769,12 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 763 | 769 | const pkg_hash = relativePathDigest(new_root, cache_root); |
| 764 | 770 | const gop = f.job_queue.table.getOrPutAssumeCapacity(pkg_hash); |
| 765 | 771 | if (gop.found_existing) { |
| 766 | | if (!dep.lazy) { |
| 772 | if (!dep.lazy and gop.value_ptr.*.lazy_status != .eager) { |
| 767 | 773 | gop.value_ptr.*.lazy_status = .eager; |
| 774 | promoted_existing_to_eager = true; |
| 775 | } else { |
| 776 | continue; |
| 768 | 777 | } |
| 769 | | continue; |
| 770 | 778 | } |
| 771 | 779 | gop.value_ptr.* = new_fetch; |
| 772 | 780 | break :l .{ .relative_path = new_root }; |
| ... | ... | @@ -774,7 +782,9 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 774 | 782 | }; |
| 775 | 783 | prog_names[new_fetch_index] = dep_name; |
| 776 | 784 | new_fetch_index += 1; |
| 777 | | f.job_queue.all_fetches.appendAssumeCapacity(new_fetch); |
| 785 | if (!promoted_existing_to_eager) { |
| 786 | f.job_queue.all_fetches.appendAssumeCapacity(new_fetch); |
| 787 | } |
| 778 | 788 | new_fetch.* = .{ |
| 779 | 789 | .arena = std.heap.ArenaAllocator.init(gpa), |
| 780 | 790 | .location = location, |