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:
parent
fdb0d4ad52
commit
a2bbc220e0
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in New Issue