Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/settings/lib/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,12 @@ public function uninstallApp(string $appId): JSONResponse {
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);
Expand Down
12 changes: 12 additions & 0 deletions core/Command/App/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
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;
Expand Down Expand Up @@ -77,13 +79,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$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) {
$updateFound = true;
$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) {
Expand Down
7 changes: 7 additions & 0 deletions lib/private/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,14 @@ private function isCodeUpgrade(): bool {
* @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)) {
Expand Down
Loading