Compare commits

...

3 Commits

Author SHA1 Message Date
Dylan Conway
18d612f424 Merge branch 'main' into dylan/fix-install-out-of-bounds 2024-04-11 18:57:46 -07:00
Dylan Conway
ea10b2ebe9 Merge branch 'main' into dylan/fix-install-out-of-bounds 2024-04-10 16:08:24 -07:00
Dylan Conway
10f0af0c07 remap dependencies ids in task_queue 2024-04-08 21:54:50 -07:00
2 changed files with 22 additions and 9 deletions

View File

@@ -580,7 +580,7 @@ pub const PreinstallState = enum(u2) {
/// Schedule long-running callbacks for a task
/// Slow stuff is broken into tasks, each can run independently without locks
const Task = struct {
pub const Task = struct {
tag: Tag,
request: Request,
data: Data,
@@ -2324,17 +2324,11 @@ const NodeModulesFolder = struct {
pub const Resolution = @import("./resolution.zig").Resolution;
const Progress = std.Progress;
const TaggedPointer = @import("../tagged_pointer.zig");
const TaskCallbackContext = union(Tag) {
const TaskCallbackContext = union(enum) {
dependency: DependencyID,
node_modules_folder: NodeModulesFolder,
root_dependency: DependencyID,
root_request_id: PackageID,
pub const Tag = enum {
dependency,
node_modules_folder,
root_dependency,
root_request_id,
};
};
const TaskCallbackList = std.ArrayListUnmanaged(TaskCallbackContext);

View File

@@ -2841,7 +2841,26 @@ pub const Package = extern struct {
package_id_mapping[this.meta.id] = new_package.meta.id;
for (old_dependencies, dependencies) |old_dep, *new_dep| {
for (old_dependencies, this.dependencies.off.., dependencies, prev_len..) |old_dep, old_id, *new_dep, new_id| {
// If this dependency was enqueued before cleaning and still has an entry in
// the task queue, make sure the id is remapped
if (old_dep.version.tag.isNPM()) {
const dep_name = old_dep.name.slice(old_string_buf);
if (PackageManager.instance.task_queue.getEntry(Install.Task.Id.forManifest(dep_name))) |entry| {
for (entry.value_ptr.items) |*task_list_item| {
switch (task_list_item.*) {
.dependency, .root_dependency => |*old_task_id| {
if (old_task_id.* == old_id) {
old_task_id.* = @intCast(new_id);
}
},
else => {},
}
}
}
}
new_dep.* = try old_dep.clone(
old_string_buf,
*Lockfile.StringBuilder,