fix: Throw AppNotFoundException from installer when application is not found

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/53352/head
Côme Chilliet 7 months ago
parent 580911dc89
commit c85f7eacb8
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
  1. 3
      apps/provisioning_api/lib/Controller/AppsController.php
  2. 1
      lib/composer/composer/autoload_classmap.php
  3. 1
      lib/composer/composer/autoload_static.php
  4. 13
      lib/private/App/AppStore/AppNotFoundException.php
  5. 6
      lib/private/Installer.php

@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OCA\Provisioning_API\Controller;
use OC\App\AppStore\AppNotFoundException;
use OC\Installer;
use OC_App;
use OCP\App\AppPathNotFoundException;
@ -124,7 +125,7 @@ class AppsController extends OCSController {
$this->appManager->enableApp($app);
} catch (\InvalidArgumentException $e) {
throw new OCSException($e->getMessage(), OCSController::RESPOND_UNAUTHORISED);
} catch (AppPathNotFoundException $e) {
} catch (AppPathNotFoundException|AppNotFoundException $e) {
throw new OCSException('The request app was not found', OCSController::RESPOND_NOT_FOUND);
}
return new DataResponse();

@ -1049,6 +1049,7 @@ return array(
'OC\\AppScriptDependency' => $baseDir . '/lib/private/AppScriptDependency.php',
'OC\\AppScriptSort' => $baseDir . '/lib/private/AppScriptSort.php',
'OC\\App\\AppManager' => $baseDir . '/lib/private/App/AppManager.php',
'OC\\App\\AppStore\\AppNotFoundException' => $baseDir . '/lib/private/App/AppStore/AppNotFoundException.php',
'OC\\App\\AppStore\\Bundles\\Bundle' => $baseDir . '/lib/private/App/AppStore/Bundles/Bundle.php',
'OC\\App\\AppStore\\Bundles\\BundleFetcher' => $baseDir . '/lib/private/App/AppStore/Bundles/BundleFetcher.php',
'OC\\App\\AppStore\\Bundles\\EducationBundle' => $baseDir . '/lib/private/App/AppStore/Bundles/EducationBundle.php',

@ -1090,6 +1090,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\AppScriptDependency' => __DIR__ . '/../../..' . '/lib/private/AppScriptDependency.php',
'OC\\AppScriptSort' => __DIR__ . '/../../..' . '/lib/private/AppScriptSort.php',
'OC\\App\\AppManager' => __DIR__ . '/../../..' . '/lib/private/App/AppManager.php',
'OC\\App\\AppStore\\AppNotFoundException' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/AppNotFoundException.php',
'OC\\App\\AppStore\\Bundles\\Bundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/Bundle.php',
'OC\\App\\AppStore\\Bundles\\BundleFetcher' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/BundleFetcher.php',
'OC\\App\\AppStore\\Bundles\\EducationBundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/EducationBundle.php',

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\App\AppStore;
class AppNotFoundException extends \Exception {
}

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace OC;
use Doctrine\DBAL\Exception\TableExistsException;
use OC\App\AppStore\AppNotFoundException;
use OC\App\AppStore\Bundles\Bundle;
use OC\App\AppStore\Fetcher\AppFetcher;
use OC\AppFramework\Bootstrap\Coordinator;
@ -174,6 +175,7 @@ class Installer {
* @param string $appId
* @param bool [$allowUnstable]
*
* @throws AppNotFoundException If the app is not found on the appstore
* @throws \Exception If the installation was not successful
*/
public function downloadApp(string $appId, bool $allowUnstable = false): void {
@ -356,9 +358,9 @@ class Installer {
}
}
throw new \Exception(
throw new AppNotFoundException(
sprintf(
'Could not download app %s',
'Could not download app %s, it was not found on the appstore',
$appId
)
);

Loading…
Cancel
Save