chore: Check if apps directory is really writable in Installer

...rather than checkServer.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2025-07-10 11:31:59 +02:00
parent 12c0cfc977
commit edf096a09f
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
2 changed files with 10 additions and 14 deletions

View file

@ -171,10 +171,20 @@ class Installer {
/**
* Get the path where to install apps
*
* @throws \RuntimeException if an app folder is marked as writable but is missing permissions
*/
public function getInstallPath(): ?string {
foreach (\OC::$APPSROOTS as $dir) {
if (isset($dir['writable']) && $dir['writable'] === true) {
// Check if there is a writable install folder.
if (!is_writable($dir['path'])
|| !is_readable($dir['path'])
) {
throw new \RuntimeException(
'Cannot write into "apps" directory. This can usually be fixed by giving the web server write access to the apps directory or disabling the App Store in the config file.'
);
}
return $dir['path'];
}
}

View file

@ -343,20 +343,6 @@ class OC_Util {
}
}
// Check if there is a writable install folder.
if ($config->getValue('appstoreenabled', true)) {
$installPath = \OCP\Server::get(\OC\Installer::class)->getInstallPath();
if ($installPath === null
|| !is_writable($installPath)
|| !is_readable($installPath)
) {
$errors[] = [
'error' => $l->t('Cannot write into "apps" directory.'),
'hint' => $l->t('This can usually be fixed by giving the web server write access to the apps directory'
. ' or disabling the App Store in the config file.')
];
}
}
// Create root dir.
if ($config->getValue('installed', false)) {
if (!is_dir($CONFIG_DATADIRECTORY)) {