Try a different approach for tars

This commit is contained in:
Simon Quigley 2025-01-25 18:03:25 -06:00
parent 3bad275726
commit 345081b851
2 changed files with 25 additions and 22 deletions

View File

@ -1149,24 +1149,22 @@ std::string CiLogic::queue_pull_tarball(std::vector<std::shared_ptr<PackageConf>
std::shared_ptr<Task> tarball_task = std::make_shared<Task>(); std::shared_ptr<Task> tarball_task = std::make_shared<Task>();
task_queue->enqueue( task_queue->enqueue(
job_statuses->at("pull"), job_statuses->at("pull"),
[this, r, &task_queue, &tarball_task, job_statuses](std::shared_ptr<Log> log) mutable { [this, r](std::shared_ptr<Log> log) mutable {
std::shared_ptr<PackageConf> pkgconf = log->get_task_context()->get_parent_packageconf(); pull_project(r, log);
if (pull_project(pkgconf, log)) {
task_queue->enqueue(
job_statuses->at("tarball"),
[this, r](std::shared_ptr<Log> log) mutable {
bool tarball_ok = create_project_tarball(r, log);
},
r
);
tarball_task = r->get_task_by_jobstatus(job_statuses->at("tarball"));
}
}, },
r r
); );
new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses->at("pull")); new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses->at("pull"));
new_item->first_tarball_task = tarball_task;
task_queue->enqueue(
job_statuses->at("tarball"),
[this, r](std::shared_ptr<Log> log) mutable {
create_project_tarball(r, log);
},
r
);
new_item->first_tarball_task = r->get_task_by_jobstatus(job_statuses->at("tarball"));
new_item->first_pkgconf = r; new_item->first_pkgconf = r;
new_item->packaging_commit = r->packaging_commit; new_item->packaging_commit = r->packaging_commit;

View File

@ -95,17 +95,22 @@ void TaskQueue::worker_thread() {
bool found_valid = false; bool found_valid = false;
// Iterate through the set until a valid task is found // Iterate through the set until a valid task is found
while (it != tasks_.end()) { while (it != tasks_.end()) {
std::shared_ptr<Task> it_task = *it; {
task_to_execute = it_task; std::shared_ptr<Task> it_task = *it;
task_to_execute = it_task;
}
int pkgconf_id = task_to_execute->get_parent_packageconf()->id; int pkgconf_id = task_to_execute->get_parent_packageconf()->id;
std::lock_guard<std::mutex> lock(running_pkgconfs_mutex_); {
auto running_pkgconf_it = std::find_if(running_pkgconfs_.begin(), running_pkgconfs_.end(), std::lock_guard<std::mutex> lock(running_pkgconfs_mutex_);
[&pkgconf_id](const std::shared_ptr<PackageConf>& pkgconf) { return pkgconf->id == pkgconf_id; }); auto running_pkgconf_it = std::find_if(running_pkgconfs_.begin(), running_pkgconfs_.end(),
[&pkgconf_id](const std::shared_ptr<PackageConf>& pkgconf) { return pkgconf->id == pkgconf_id; });
if (running_pkgconf_it != running_pkgconfs_.end()) { if (running_pkgconf_it != running_pkgconfs_.end()) {
++it; // Move to the next task ++it; // Move to the next task
continue; continue;
}
} }
// Task is valid to execute // Task is valid to execute