|
|
|
|
@ -169,6 +169,18 @@ class Installer { |
|
|
|
|
return $matches[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get the path where to install apps |
|
|
|
|
*/ |
|
|
|
|
public function getInstallPath(): ?string { |
|
|
|
|
foreach (\OC::$APPSROOTS as $dir) { |
|
|
|
|
if (isset($dir['writable']) && $dir['writable'] === true) { |
|
|
|
|
return $dir['path']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Downloads an app and puts it into the app directory |
|
|
|
|
* |
|
|
|
|
@ -181,6 +193,11 @@ class Installer { |
|
|
|
|
public function downloadApp(string $appId, bool $allowUnstable = false): void { |
|
|
|
|
$appId = strtolower($appId); |
|
|
|
|
|
|
|
|
|
$installPath = $this->getInstallPath(); |
|
|
|
|
if ($installPath === null) { |
|
|
|
|
throw new \Exception('No application directories are marked as writable.'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$apps = $this->appFetcher->get($allowUnstable); |
|
|
|
|
foreach ($apps as $app) { |
|
|
|
|
if ($app['id'] === $appId) { |
|
|
|
|
@ -333,7 +350,7 @@ class Installer { |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$baseDir = OC_App::getInstallPath() . '/' . $appId; |
|
|
|
|
$baseDir = $installPath . '/' . $appId; |
|
|
|
|
// Remove old app with the ID if existent |
|
|
|
|
Files::rmdirr($baseDir); |
|
|
|
|
// Move to app folder |
|
|
|
|
@ -375,7 +392,7 @@ class Installer { |
|
|
|
|
*/ |
|
|
|
|
public function isUpdateAvailable($appId, $allowUnstable = false): string|false { |
|
|
|
|
if ($this->isInstanceReadyForUpdates === null) { |
|
|
|
|
$installPath = OC_App::getInstallPath(); |
|
|
|
|
$installPath = $this->getInstallPath(); |
|
|
|
|
if ($installPath === null) { |
|
|
|
|
$this->isInstanceReadyForUpdates = false; |
|
|
|
|
} else { |
|
|
|
|
@ -463,7 +480,13 @@ class Installer { |
|
|
|
|
if (\OCP\Server::get(IAppManager::class)->isShipped($appId)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$appDir = OC_App::getInstallPath() . '/' . $appId; |
|
|
|
|
|
|
|
|
|
$installPath = $this->getInstallPath(); |
|
|
|
|
if ($installPath === null) { |
|
|
|
|
$this->logger->error('No application directories are marked as writable.', ['app' => 'core']); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$appDir = $installPath . '/' . $appId; |
|
|
|
|
Files::rmdirr($appDir); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
|