Skip to content

Commit 600178d

Browse files
solracsfAltahrim
authored andcommitted
feat(occ): Better handling of disabled or unreacheable App store
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 0302d60 commit 600178d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

core/Command/App/Update.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OC\Installer;
1313
use OCP\App\AppPathNotFoundException;
1414
use OCP\App\IAppManager;
15+
use OCP\IConfig;
1516
use Psr\Log\LoggerInterface;
1617
use Symfony\Component\Console\Command\Command;
1718
use Symfony\Component\Console\Input\InputArgument;
@@ -20,8 +21,11 @@
2021
use Symfony\Component\Console\Output\OutputInterface;
2122

2223
class Update extends Command {
24+
public const APP_STORE_URL = 'https://apps.nextcloud.com/api/v1';
25+
2326
public function __construct(
2427
protected IAppManager $manager,
28+
protected IConfig $config,
2529
private Installer $installer,
2630
private LoggerInterface $logger,
2731
) {
@@ -67,6 +71,19 @@ protected function configure(): void {
6771

6872
#[\Override]
6973
protected function execute(InputInterface $input, OutputInterface $output): int {
74+
$appStoreEnabled = $this->config->getSystemValueBool('appstoreenabled', true);
75+
if ($appStoreEnabled === false) {
76+
$output->writeln('App store access is disabled');
77+
return 1;
78+
}
79+
80+
$internetAvailable = $this->config->getSystemValueBool('has_internet_connection', true);
81+
$isDefaultAppStore = $this->config->getSystemValueString('appstoreurl', self::APP_STORE_URL) === self::APP_STORE_URL;
82+
if ($internetAvailable === false && $isDefaultAppStore === true) {
83+
$output->writeln('Internet connection is disabled, and therefore the default public App store is not reachable');
84+
return 1;
85+
}
86+
7087
$singleAppId = $input->getArgument('app-id');
7188
$updateFound = false;
7289
$showOnly = $input->getOption('showonly') || $input->getOption('showcurrent');

0 commit comments

Comments
 (0)