Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for naming conflicts before returning the user mounts #523

Merged
merged 2 commits into from
Aug 23, 2019

Conversation

juliusknorr
Copy link
Member

This PR makes sure we check and rename existing files/shares to a unique name before the groupfolder mount is added to the user mounts.

Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliusknorr
Copy link
Member Author

@rullzer Any feedback on the approach? I think performance wise this should be fine since it basically adds only one check for existing file by default.

@@ -85,7 +85,19 @@ public function getFoldersForUser(IUser $user) {
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$folders = $this->getFoldersForUser($user);

return array_map(function ($folder) use ($user, $loader) {
/** @var Folder $folder */
$userHome = \OC::$server->getRootFolder()->getUserFolder($user->getUID());
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this trigger cyclic things?

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't seem so when testing, but indeed this seems like it could cause issues. I'll dig a bit deeper tomorrow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks fine, as the mountpoints are only setup once for the user. So when getRootFolder is called, initMountPoints will not execute again.

https://github.com/nextcloud/server/blob/1b85ef4bf2a18f7ee7bca7bcd3d7702362125d2e/lib/private/Files/Filesystem.php#L403

The issue I see would be that mount providers that are registered after the group folder provider don't have their mountpoints added to the user root at that point. For sharing mounts this is handled by manually forcing that mount provider to be the last mounted. https://github.com/nextcloud/server/blob/3ad6084891b88b3b7ef784bbf297b0a57b282d77/lib/private/Files/Config/MountProviderCollection.php#L93-L101

But I assume we should only rename regular users files anyway, so that shouldn't be an issue?

Copy link
Member

Choose a reason for hiding this comment

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

Ok lets just try it then...

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

Lets give this a shot

@juliusknorr
Copy link
Member Author

@icewind1991 Would be great if you could have a look as well

@rullzer rullzer merged commit 3a66ae8 into master Aug 23, 2019
@delete-merged-branch delete-merged-branch bot deleted the bugfix/18/rename-before.mount branch August 23, 2019 14:39
@juliusknorr
Copy link
Member Author

/backport to stable4

@backportbot-nextcloud
Copy link

backport to stable4 in #568

@wiswedel
Copy link
Contributor

Fixes #18

@rullzer
Copy link
Member

rullzer commented Oct 21, 2019

Ok so I was right. It does make boom. Due to cyclic nitialization. And actually causes: #597

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.

3 participants