Change order of share creation validation

Makes sure that the share owner is set before entering the checks that
need it.

Partial backport of afa37d3
This commit is contained in:
Vincent Petry 2016-07-05 10:58:00 +02:00
parent fdb0d4ad52
commit a2bbc220e0
No known key found for this signature in database
GPG Key ID: AF8F9EFC56562186
1 changed files with 18 additions and 18 deletions

View File

@ -505,6 +505,24 @@ class Manager implements IManager {
$this->generalCreateChecks($share); $this->generalCreateChecks($share);
// Verify if there are any issues with the path
$this->pathCreateChecks($share->getNode());
/*
* On creation of a share the owner is always the owner of the path
* Except for mounted federated shares.
*/
$storage = $share->getNode()->getStorage();
if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
$parent = $share->getNode()->getParent();
while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
$parent = $parent->getParent();
}
$share->setShareOwner($parent->getOwner()->getUID());
} else {
$share->setShareOwner($share->getNode()->getOwner()->getUID());
}
//Verify share type //Verify share type
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$this->userCreateChecks($share); $this->userCreateChecks($share);
@ -538,24 +556,6 @@ class Manager implements IManager {
} }
} }
// Verify if there are any issues with the path
$this->pathCreateChecks($share->getNode());
/*
* On creation of a share the owner is always the owner of the path
* Except for mounted federated shares.
*/
$storage = $share->getNode()->getStorage();
if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
$parent = $share->getNode()->getParent();
while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
$parent = $parent->getParent();
}
$share->setShareOwner($parent->getOwner()->getUID());
} else {
$share->setShareOwner($share->getNode()->getOwner()->getUID());
}
// Cannot share with the owner // Cannot share with the owner
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) { $share->getSharedWith() === $share->getShareOwner()) {