Compare commits

...

1 Commits

Author SHA1 Message Date
Git'Fellow
3040762a2b feat(updater): Allow to defined locked apps
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
2025-09-13 15:30:41 +02:00
3 changed files with 25 additions and 0 deletions

View File

@@ -650,6 +650,12 @@ class AppSettingsController extends Controller {
public function updateApp(string $appId): JSONResponse {
$appId = $this->appManager->cleanAppId($appId);
// Don't try to update locked apps
$appsLocked = $this->config->getSystemValue('apps_locked', []);
if (in_array($appId, $appsLocked, true)) {
return new JSONResponse(['data' => ['message' => $this->l10n->t('App is locked, update skipped.')]], Http::STATUS_FORBIDDEN);
}
$this->config->setSystemValue('maintenance', true);
try {
$result = $this->installer->updateAppstoreApp($appId);

View File

@@ -11,6 +11,8 @@ namespace OC\Core\Command\App;
use OC\Installer;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\Server;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
@@ -77,6 +79,10 @@ class Update extends Command {
}
$return = 0;
$config = Server::get(IConfig::class);
$appsLocked = $config->getSystemValue('apps_locked', []);
foreach ($apps as $appId) {
$newVersion = $this->installer->isUpdateAvailable($appId, $input->getOption('allow-unstable'));
if ($newVersion) {
@@ -84,6 +90,12 @@ class Update extends Command {
$output->writeln($appId . ' new version available: ' . $newVersion);
if (!$input->getOption('showonly')) {
// Don't try to update locked apps
if (in_array($appId, $appsLocked, true)) {
$output->writeln('Update skipped for locked app ' . $appId);
continue;
}
try {
$result = $this->installer->updateAppstoreApp($appId, $input->getOption('allow-unstable'));
} catch (\Exception $e) {

View File

@@ -373,7 +373,14 @@ class Updater extends BasicEmitter {
* @throws \Exception
*/
private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []): void {
$appsLocked = $this->config->getSystemValue('apps_locked', []);
foreach ($apps as $app) {
// Don't try to update locked apps
if (in_array($app, $appsLocked, true)) {
$this->log->info('Update skipped for locked app' . $app, ['app' => 'updater']);
continue;
}
try {
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
if ($this->installer->isUpdateAvailable($app)) {