Skip to content

Commit

Permalink
fix(apps-store): Remove apps from force-enabled state when uninstalled
Browse files Browse the repository at this point in the history
If an app is force-enabled and then uninstalled the force-enabled state was kept.
This is now removed, so when the app should be re-installed the compatibility should be reevaluated.

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Oct 23, 2024
1 parent 74cd6e2 commit cb45a3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/settings/lib/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,8 @@ public function uninstallApp(string $appId): JSONResponse {
$appId = $this->appManager->cleanAppId($appId);
$result = $this->installer->removeApp($appId);
if ($result !== false) {
// If this app was force enabled, remove the force-enabled-state
$this->appManager->ignoreNextcloudRequirementForApp($appId, false);
$this->appManager->clearAppsCache();
return new JSONResponse(['data' => ['appid' => $appId]]);
}
Expand Down
1 change: 1 addition & 0 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@
<file src="apps/settings/lib/Controller/AppSettingsController.php">
<UndefinedInterfaceMethod>
<code><![CDATA[ignoreNextcloudRequirementForApp]]></code>
<code><![CDATA[ignoreNextcloudRequirementForApp]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="apps/settings/lib/Hooks.php">
Expand Down
8 changes: 5 additions & 3 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,14 @@ public function isInstalled($appId) {
return isset($installedApps[$appId]);
}

public function ignoreNextcloudRequirementForApp(string $appId): void {
public function ignoreNextcloudRequirementForApp(string $appId, bool $enabled = true): void {
$ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []);
if (!in_array($appId, $ignoreMaxApps, true)) {
if ($enabled && !in_array($appId, $ignoreMaxApps, true)) {
$ignoreMaxApps[] = $appId;
$this->config->setSystemValue('app_install_overwrite', $ignoreMaxApps);
} elseif ($enabled === false) {
$ignoreMaxApps = array_filter($ignoreMaxApps, fn (string $id) => $id !== $appId);
}
$this->config->setSystemValue('app_install_overwrite', $ignoreMaxApps);
}

public function loadApp(string $app): void {
Expand Down

0 comments on commit cb45a3b

Please sign in to comment.