Skip to content

Commit

Permalink
fix: PM blocked in a cancled task
Browse files Browse the repository at this point in the history
Set the runningTaskObjectPath before the next available
task start instead of after the last task finished.

Log:
  • Loading branch information
kamiyadm authored and dengbo11 committed Dec 18, 2024
1 parent e5200c9 commit e679804
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions libs/linglong/src/linglong/package_manager/package_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,14 @@ PackageManager::PackageManager(linglong::repo::OSTreeRepo &repo, QObject *parent
}
return;
}
// start next task
this->runningTaskObjectPath = taskObjectPath;
if (this->taskList.empty()) {
this->runningTaskObjectPath = "";
return;
};

for (auto it = taskList.begin(); it != taskList.end(); ++it) {
auto *task = *it;
if (!task->getJob().has_value()
|| task->state() != linglong::api::types::v1::State::Queued) {
continue;
}
this->runningTaskObjectPath = task->taskObjectPath();
// execute the task
qInfo() << QString("Task %1 start.").arg(task->taskID());
auto func = *task->getJob();
Expand All @@ -142,8 +138,8 @@ PackageManager::PackageManager(linglong::repo::OSTreeRepo &repo, QObject *parent
auto nextIt = this->taskList.erase(it);
task->deleteLater();
if (nextIt != taskList.end()) {
qInfo() << "Task switch to" << (*nextIt)->taskID();
Q_EMIT this->TaskListChanged((*nextIt)->taskID(), "TaskSwitch");
qInfo() << "Switch to next available task";
Q_EMIT this->TaskListChanged("", "TaskSwitch");
}
return;
}
Expand Down

0 comments on commit e679804

Please sign in to comment.