-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Group shares with same source and target #25113
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
Changes from all commits
aa42b7b
e5af146
c97bb28
cb683dd
fb0f186
c4db9ad
d0244f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,10 @@ class SharedMount extends MountPoint implements MoveableMount { | |
| private $user; | ||
|
|
||
| /** @var \OCP\Share\IShare */ | ||
| private $share; | ||
| private $superShare; | ||
|
|
||
| /** @var \OCP\Share\IShare[] */ | ||
| private $groupedShares; | ||
|
|
||
| /** | ||
| * @param string $storage | ||
|
|
@@ -61,10 +64,13 @@ class SharedMount extends MountPoint implements MoveableMount { | |
| public function __construct($storage, array $mountpoints, $arguments = null, $loader = null) { | ||
| $this->user = $arguments['user']; | ||
| $this->recipientView = new View('/' . $this->user . '/files'); | ||
| $this->share = $arguments['newShare']; | ||
| $newMountPoint = $this->verifyMountPoint($this->share, $mountpoints); | ||
|
|
||
| $this->superShare = $arguments['superShare']; | ||
| $this->groupedShares = $arguments['groupedShares']; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose another enhanced approach would be to define a new class This could have the advantage of being reusable in other contexts where grouping is required.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that! |
||
|
|
||
| $newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints); | ||
| $absMountPoint = '/' . $this->user . '/files' . $newMountPoint; | ||
| $arguments['ownerView'] = new View('/' . $this->share->getShareOwner() . '/files'); | ||
| $arguments['ownerView'] = new View('/' . $this->superShare->getShareOwner() . '/files'); | ||
| parent::__construct($storage, $absMountPoint, $arguments, $loader); | ||
| } | ||
|
|
||
|
|
@@ -106,7 +112,11 @@ private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints) | |
| */ | ||
| private function updateFileTarget($newPath, &$share) { | ||
| $share->setTarget($newPath); | ||
| \OC::$server->getShareManager()->moveShare($share, $this->user); | ||
|
|
||
| foreach ($this->groupedShares as $share) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conflict with the "share" variable from the method argument. Also I'm confused why we are relying on the internal
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah fair enough. Yeah it needs to be cleaned up more. Basically the groupedShares are always there now. The 'regual' share is just a super set of all shares. I did it this way so we have less code paths. So we even if you have just 1 incomming share then you will have a 'super' share with the same stuff. And I prefer 1 code path. |
||
| $share->setTarget($newPath); | ||
| \OC::$server->getShareManager()->moveShare($share, $this->user); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -212,7 +222,7 @@ public function removeMount() { | |
| * @return \OCP\Share\IShare | ||
| */ | ||
| public function getShare() { | ||
| return $this->share; | ||
| return $this->superShare; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -221,6 +231,6 @@ public function getShare() { | |
| * @return int | ||
| */ | ||
| public function getStorageRootId() { | ||
| return $this->share->getNodeId(); | ||
| return $this->getShare()->getNodeId(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rullzer Shouldn't nodeId and target be combined into a single key ? That is, if you're grouping by these too, unless this is doing something slightly different.
Once I understand this I'll update the PHPDoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it would likely yield the same results anyway.
Whenever a single folder is has two shares, one with group and one with user, as long as the target is the same they need to stay combined. Once the user renamed the target, they need to stay split. That makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is the 'old' behaviour anyways.
I'm not convinced that is always the right approach. Ideally I just see 1 entry per share. Else you also get duplicated data if you sync etc.
But lets make it behave like in the old days first.