chore: Add IAppManager property in Installer

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/53895/head
Côme Chilliet 2025-07-10 16:04:46 +07:00
parent fd17555333
commit 42c980e093
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
2 changed files with 6 additions and 17 deletions

@ -43,6 +43,7 @@ class Installer {
private ITempManager $tempManager, private ITempManager $tempManager,
private LoggerInterface $logger, private LoggerInterface $logger,
private IConfig $config, private IConfig $config,
private IAppManager $appManager,
private bool $isCLI, private bool $isCLI,
) { ) {
} }
@ -68,7 +69,7 @@ class Installer {
} }
$l = \OCP\Util::getL10N('core'); $l = \OCP\Util::getL10N('core');
$info = \OCP\Server::get(IAppManager::class)->getAppInfoByPath($basedir . '/appinfo/info.xml', $l->getLanguageCode()); $info = $this->appManager->getAppInfoByPath($basedir . '/appinfo/info.xml', $l->getLanguageCode());
if (!is_array($info)) { if (!is_array($info)) {
throw new \Exception( throw new \Exception(
@ -120,7 +121,7 @@ class Installer {
$config = \OCP\Server::get(IConfig::class); $config = \OCP\Server::get(IConfig::class);
//set the installed version //set the installed version
$config->setAppValue($info['id'], 'installed_version', \OCP\Server::get(IAppManager::class)->getAppVersion($info['id'], false)); $config->setAppValue($info['id'], 'installed_version', $this->appManager->getAppVersion($info['id'], false));
$config->setAppValue($info['id'], 'enabled', 'no'); $config->setAppValue($info['id'], 'enabled', 'no');
//set remote/public handlers //set remote/public handlers
@ -347,7 +348,7 @@ class Installer {
} }
// Check if the version is lower than before // Check if the version is lower than before
$currentVersion = \OCP\Server::get(IAppManager::class)->getAppVersion($appId, true); $currentVersion = $this->appManager->getAppVersion($appId, true);
$newVersion = (string)$xml->version; $newVersion = (string)$xml->version;
if (version_compare($currentVersion, $newVersion) === 1) { if (version_compare($currentVersion, $newVersion) === 1) {
throw new \Exception( throw new \Exception(
@ -424,7 +425,7 @@ class Installer {
foreach ($this->apps as $app) { foreach ($this->apps as $app) {
if ($app['id'] === $appId) { if ($app['id'] === $appId) {
$currentVersion = \OCP\Server::get(IAppManager::class)->getAppVersion($appId, true); $currentVersion = $this->appManager->getAppVersion($appId, true);
if (!isset($app['releases'][0]['version'])) { if (!isset($app['releases'][0]['version'])) {
return false; return false;
@ -487,7 +488,7 @@ class Installer {
*/ */
public function removeApp(string $appId): bool { public function removeApp(string $appId): bool {
if ($this->isDownloaded($appId)) { if ($this->isDownloaded($appId)) {
if (\OCP\Server::get(IAppManager::class)->isShipped($appId)) { if ($this->appManager->isShipped($appId)) {
return false; return false;
} }

@ -12,7 +12,6 @@ use NCU\Security\Signature\ISignatureManager;
use OC\Accounts\AccountManager; use OC\Accounts\AccountManager;
use OC\App\AppManager; use OC\App\AppManager;
use OC\App\AppStore\Bundles\BundleFetcher; use OC\App\AppStore\Bundles\BundleFetcher;
use OC\App\AppStore\Fetcher\AppFetcher;
use OC\AppFramework\Bootstrap\Coordinator; use OC\AppFramework\Bootstrap\Coordinator;
use OC\AppFramework\Http\Request; use OC\AppFramework\Http\Request;
use OC\AppFramework\Http\RequestId; use OC\AppFramework\Http\RequestId;
@ -1171,17 +1170,6 @@ class Server extends ServerContainer implements IServerContainer {
); );
}); });
$this->registerService(Installer::class, function (ContainerInterface $c) {
return new Installer(
$c->get(AppFetcher::class),
$c->get(IClientService::class),
$c->get(ITempManager::class),
$c->get(LoggerInterface::class),
$c->get(\OCP\IConfig::class),
\OC::$CLI
);
});
$this->registerService(IApiFactory::class, function (ContainerInterface $c) { $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
return new ApiFactory($c->get(IClientService::class)); return new ApiFactory($c->get(IClientService::class));
}); });