Skip to content

Commit 24a5bfc

Browse files
authored
feat(occ): Better handling of disabled appstore
Signed-off-by: Git'Fellow <[email protected]>
1 parent ad045d6 commit 24a5bfc

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

core/Command/App/Update.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OC\Installer;
1212
use OCP\App\IAppManager;
13+
use OCP\IConfig;
1314
use Psr\Log\LoggerInterface;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputArgument;
@@ -18,8 +19,11 @@
1819
use Symfony\Component\Console\Output\OutputInterface;
1920

2021
class Update extends Command {
22+
public const APP_STORE_URL = 'https://apps.nextcloud.com/api/v1';
23+
2124
public function __construct(
2225
protected IAppManager $manager,
26+
protected IConfig $config,
2327
private Installer $installer,
2428
private LoggerInterface $logger,
2529
) {
@@ -57,6 +61,20 @@ protected function configure(): void {
5761
}
5862

5963
protected function execute(InputInterface $input, OutputInterface $output): int {
64+
$appStoreEnabled = $this->config->getSystemValueBool('appstoreenabled', true);
65+
$internetAvailable = $this->config->getSystemValueBool('has_internet_connection', true);
66+
$isDefaultAppStore = $this->config->getSystemValueString('appstoreurl', self::APP_STORE_URL) === self::APP_STORE_URL;
67+
68+
if (!$appStoreEnabled) {
69+
$output->writeln('App store access is disabled');
70+
return 1;
71+
}
72+
73+
if (!$internetAvailable && $isDefaultAppStore) {
74+
$output->writeln('This instance has no internet connection to access the default App store');
75+
return 1;
76+
}
77+
6078
$singleAppId = $input->getArgument('app-id');
6179
$updateFound = false;
6280

0 commit comments

Comments
 (0)