Skip to content

Commit

Permalink
fix: install app failed after it was cancled before
Browse files Browse the repository at this point in the history
The job which the state is not Queued or has no job should be remove.

Log:
  • Loading branch information
kamiyadm authored and dengbo11 committed Dec 19, 2024
1 parent e679804 commit 8a6c221
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,13 @@ PackageManager::PackageManager(linglong::repo::OSTreeRepo &repo, QObject *parent
return;
}

for (auto it = taskList.begin(); it != taskList.end(); ++it) {
for (auto it = taskList.begin(); it != taskList.end();) {
auto *task = *it;
if (!task->getJob().has_value()
|| task->state() != linglong::api::types::v1::State::Queued) {
qInfo() << "Remove" << task->taskID()
<< "from task queue, it has no job or State is not Queued";
it = this->taskList.erase(it);
continue;
}
this->runningTaskObjectPath = task->taskObjectPath();
Expand All @@ -135,9 +138,9 @@ PackageManager::PackageManager(linglong::repo::OSTreeRepo &repo, QObject *parent
task->message(),
task->getPercentage());
this->runningTaskObjectPath = "";
auto nextIt = this->taskList.erase(it);
it = this->taskList.erase(it);
task->deleteLater();
if (nextIt != taskList.end()) {
if (it != taskList.end()) {
qInfo() << "Switch to next available task";
Q_EMIT this->TaskListChanged("", "TaskSwitch");
}
Expand Down
6 changes: 5 additions & 1 deletion libs/linglong/src/linglong/package_manager/package_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ class PackageTask : public QObject, protected QDBusContext

auto cancellable() noexcept { return m_cancelFlag; }

bool isRefExist(const QString &ref) const noexcept { return m_refs.contains(ref); }
bool isRefExist(const QString &ref) const noexcept
{
return m_refs.contains(ref)
&& this->m_state != static_cast<int>(linglong::api::types::v1::State::Canceled);
}

auto getJob() { return m_job; }

Expand Down

0 comments on commit 8a6c221

Please sign in to comment.