Skip to content

Conversation

@provokateurin
Copy link
Member

Summary

Most of the logic was quite broken regarding read-only app roots, both on backend and frontend. In general app roots seem to be a feature that isn't used a lot (at least in production, maybe more in development), otherwise some of these issues would have come up way earlier (but for example git apps are ignored for updates, so most developers will never see it broken with multiple app roots).
I'm sure there are more bugs, as the code is just a mess and definitely hasn't been adjusted well in the past.

Checklist

@provokateurin provokateurin added bug 3. to review Waiting for reviews labels Mar 24, 2025
@provokateurin provokateurin added this to the Nextcloud 32 milestone Mar 24, 2025
@provokateurin provokateurin requested a review from susnux March 24, 2025 13:47
@provokateurin provokateurin requested review from a team as code owners March 24, 2025 13:47
@provokateurin provokateurin requested review from ArtificialOwl, skjnldsv and sorbaugh and removed request for a team March 24, 2025 13:47
@provokateurin
Copy link
Member Author

/backport to stable31

@provokateurin
Copy link
Member Author

/backport to stable30

…pect read-only apps roots

Signed-off-by: provokateurin <kate@provokateurin.de>
… it is read-only

Signed-off-by: provokateurin <kate@provokateurin.de>
… respect read-only app roots

Signed-off-by: provokateurin <kate@provokateurin.de>
@provokateurin provokateurin force-pushed the fix/settings/read-only-apps-root branch from 5fd2fa7 to f206c60 Compare March 24, 2025 14:00
@provokateurin
Copy link
Member Author

/backport to stable29

@provokateurin
Copy link
Member Author

(One cypress failure is related!)

'active' => $this->appManager->isEnabledForUser($app['id']),
'needsDownload' => !$existsLocally,
'canDownload' => $anyAppsRootWritable,
'canUpdate' => $canUpdate,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would remove the crucial part that allows updating apps into another folder when the current one is read-only.
At least in the past we allowed an app to be in multiple app directories and the code simply loaded the one with the highest number in appinfo.xml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But unfortunately it's also the case, that some paths are hardcoded to apps/, so I'm not sure that this really worked as intended.
Like I said, app directories are very broken from what I had to dig through.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But unfortunately it's also the case, that some paths are hardcoded to apps/

What? Can you provide links?

sorbaugh
sorbaugh previously approved these changes Apr 7, 2025
@provokateurin provokateurin dismissed sorbaugh’s stale review April 7, 2025 08:19

Sorry @sorbaugh, I think this will need some considerations as this entire topic could easily break things if we are not careful.

try {
$appPath = $appManager->getAppPath($appId);
} catch (AppPathNotFoundException) {
$appPath = OC_App::getInstallPath() . '/' . $appId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OC_App::getInstallPath is only used in this class it seems, it should be moved into it and deprecated in OC_App. It should also have a better name.

*/
private function getAppsForCategory($requestedCategory = ''): array {
$anyAppsRootWritable = false;
foreach (\OC::$APPSROOTS as $appsRoot) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a public getter somewhere for app roots instead of accessing an OC static var from an application.

Also, this logic of testing whether at least one app folder is writable could be in a method of the AppManager directly.

Comment on lines +475 to +481
$appsRootWritable = false;
$appRootPath = dirname($appPath);
foreach (\OC::$APPSROOTS as $appsRoot) {
if ($appsRoot['path'] === $appRootPath) {
$appsRootWritable = $appsRoot['writable'] ?? false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is duplicated in your PR, please create a method for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mark extra apps in non-writable folders as non-removeable and non-updateable

6 participants