Skip to content

Commit

Permalink
apps: Avoid pruning unused apps on every check operation
Browse files Browse the repository at this point in the history
Only prune on startup, or when an installation is being finalized.

Signed-off-by: Andre Detsch <[email protected]>
  • Loading branch information
detsch committed Dec 5, 2024
1 parent 6f585dc commit fc04b9f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions include/aktualizr-lite/aklite_client_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class AkliteClientExt : public AkliteClient {
bool do_install = true);

bool RebootIfRequired();

private:
bool cleanup_removed_apps_{true};
};

#endif
4 changes: 3 additions & 1 deletion src/aklite_client_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ GetTargetToInstallResult AkliteClientExt::GetTargetToInstall(const CheckInResult
<< " Skipping its installation.";
}

auto apps_to_update = client_->appsToUpdate(Target::fromTufTarget(current));
auto apps_to_update = client_->appsToUpdate(Target::fromTufTarget(current), cleanup_removed_apps_);
// Automatically cleanup during check only once. A cleanup will also occur after a new target is installed
cleanup_removed_apps_ = false;
if (force_apps_sync || !apps_to_update.empty()) {
// Force installation of apps
res.selected_target = checkin_res.SelectTarget(current.Version());
Expand Down
5 changes: 3 additions & 2 deletions src/liteclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@ bool LiteClient::isTargetActive(const Uptane::Target& target) const {

bool LiteClient::appsInSync(const Uptane::Target& target) const { return appsToUpdate(target).empty(); }

ComposeAppManager::AppsSyncReason LiteClient::appsToUpdate(const Uptane::Target& target) const {
ComposeAppManager::AppsSyncReason LiteClient::appsToUpdate(const Uptane::Target& target,
bool cleanup_removed_apps) const {
if (package_manager_->name() == ComposeAppManager::Name) {
auto* compose_pacman = dynamic_cast<ComposeAppManager*>(package_manager_.get());
if (compose_pacman == nullptr) {
Expand All @@ -782,7 +783,7 @@ ComposeAppManager::AppsSyncReason LiteClient::appsToUpdate(const Uptane::Target&
}
LOG_INFO << "Checking status of Active Target (" << target.filename() << ")";
auto apps_to_update = compose_pacman->checkForAppsToUpdate(target);
if (apps_to_update.empty()) {
if (cleanup_removed_apps && apps_to_update.empty()) {
compose_pacman->handleRemovedApps(getCurrent());
}

Expand Down
2 changes: 1 addition & 1 deletion src/liteclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class LiteClient {
void reportAppsState();
bool isTargetActive(const Uptane::Target& target) const;
bool appsInSync(const Uptane::Target& target) const;
ComposeAppManager::AppsSyncReason appsToUpdate(const Uptane::Target& target) const;
ComposeAppManager::AppsSyncReason appsToUpdate(const Uptane::Target& target, bool cleanup_removed_apps = true) const;
void setAppsNotChecked();
std::string getDeviceID() const;
static void update_request_headers(std::shared_ptr<HttpClient>& http_client, const Uptane::Target& target,
Expand Down

0 comments on commit fc04b9f

Please sign in to comment.