Skip to content

Commit 1b12fd0

Browse files
authored
Merge pull request #57308 from nextcloud/jtr/fix-installer-isDownloaded-robustness
fix(installer): make isDownloaded robust + unify parameter naming
2 parents 97ba753 + 30f2932 commit 1b12fd0

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lib/private/Installer.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,16 @@ private function isInstalledFromGit(string $appId): bool {
416416
* Check if app is already downloaded
417417
*
418418
* The function will check if the app is already downloaded in the apps repository
419+
* and has a valid appinfo/info.xml file.
420+
*
421+
* @return bool True if the app directory exists
419422
*/
420-
public function isDownloaded(string $name): bool {
423+
public function isDownloaded(string $appId): bool {
421424
foreach (\OC::$APPSROOTS as $dir) {
422-
$dirToTest = $dir['path'];
423-
$dirToTest .= '/';
424-
$dirToTest .= $name;
425-
$dirToTest .= '/';
425+
$appPath = $dir['path'] . '/' . $appId;
426426

427-
if (is_dir($dirToTest)) {
427+
// An app is considered "downloaded" if the directory exists with info.xml
428+
if (is_dir($appPath) && file_exists($appPath . '/appinfo/info.xml')) {
428429
return true;
429430
}
430431
}
@@ -587,18 +588,22 @@ private function installAppLastSteps(string $appPath, array $info, ?IOutput $out
587588
}
588589

589590
/**
590-
* install an app already placed in the app folder
591+
* Install an app already placed in the app folder
592+
*
593+
* @param string $appId The app ID to install
594+
* @param IOutput|null $output Optional output handler for logging installation progress
595+
* @return string|false App ID on success, false on failure
591596
*/
592-
public function installShippedApp(string $app, ?IOutput $output = null): string|false {
597+
public function installShippedApp(string $appId, ?IOutput $output = null): string|false {
593598
if ($output instanceof IOutput) {
594-
$output->debug('Installing ' . $app);
599+
$output->debug('Installing ' . $appId);
595600
}
596-
$info = $this->appManager->getAppInfo($app);
597-
if (is_null($info) || $info['id'] !== $app) {
601+
$info = $this->appManager->getAppInfo($appId);
602+
if (is_null($info) || $info['id'] !== $appId) {
598603
return false;
599604
}
600605

601-
$appPath = $this->appManager->getAppPath($app);
606+
$appPath = $this->appManager->getAppPath($appId);
602607

603608
return $this->installAppLastSteps($appPath, $info, $output, 'yes');
604609
}

0 commit comments

Comments
 (0)