Skip to content

Commit

Permalink
fix: no package exist after update failed
Browse files Browse the repository at this point in the history
close: #470

Log:
  • Loading branch information
kamiyadm authored and dengbo11 committed Jun 5, 2024
1 parent 6bc6d3e commit 555d0b5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions libs/linglong/src/linglong/package_manager/package_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,25 +426,27 @@ void PackageManager::Update(const std::shared_ptr<InstallTask> &taskContext,
|| taskContext->currentStatus() == InstallTask::Canceled) {
return;
}
t.addRollBack([this, &newRef, &develop]() noexcept {
t.addRollBack([this, &newRef, &ref, &develop]() noexcept {
auto result = this->repo.remove(newRef, develop);
if (!result) {
qCritical() << result.error();
}
this->repo.unexportReference(newRef);
this->repo.exportReference(ref);
});

auto result = this->repo.remove(ref, develop);
if (!result) {
taskContext->updateStatus(InstallTask::Failed, result.error().message());
return;
}

this->repo.unexportReference(ref);
this->repo.exportReference(newRef);

taskContext->updateStatus(InstallTask::Success, "Upgrade " + ref.toString() + " success");
taskContext->updateStatus(InstallTask::Success,
"Upgrade " + ref.toString() + "to" + newRef.toString() + " success");
t.commit();

// try to remove old version
auto result = this->repo.remove(ref, develop);
if (!result) {
qCritical() << "Failed to remove old package: " << ref.toString();
}
}

auto PackageManager::Search(const QVariantMap &parameters) noexcept -> QVariantMap
Expand Down

0 comments on commit 555d0b5

Please sign in to comment.