mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Throw exception
This commit is contained in:
parent
ee65cd0bd8
commit
426a12baaa
3 changed files with 17 additions and 5 deletions
|
|
@ -261,7 +261,14 @@ class Manager implements IManager {
|
|||
}
|
||||
|
||||
// If expiredate is empty set a default one if there is a default
|
||||
if ($share->getFullId() === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
|
||||
$fullId = null;
|
||||
try {
|
||||
$fullId = $share->getFullId();
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
// This is a new share
|
||||
}
|
||||
|
||||
if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
|
||||
$expirationDate = new \DateTime();
|
||||
$expirationDate->setTime(0,0,0);
|
||||
$expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
|
||||
|
|
@ -360,8 +367,12 @@ class Manager implements IManager {
|
|||
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
|
||||
$existingShares = $provider->getSharesByPath($share->getNode());
|
||||
foreach($existingShares as $existingShare) {
|
||||
if ($existingShare->getFullId() === $share->getFullId()) {
|
||||
continue;
|
||||
try {
|
||||
if ($existingShare->getFullId() === $share->getFullId()) {
|
||||
continue;
|
||||
}
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
//It is a new share so just continue
|
||||
}
|
||||
|
||||
if ($existingShare->getSharedWith() === $share->getSharedWith()) {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Share implements \OCP\Share\IShare {
|
|||
*/
|
||||
public function getFullId() {
|
||||
if ($this->providerId === null || $this->id === null) {
|
||||
return null;
|
||||
throw new \UnexpectedValueException;
|
||||
}
|
||||
return $this->providerId . ':' . $this->id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,9 @@ interface IShare {
|
|||
* Get the full share id. This is the <providerid>:<internalid>.
|
||||
* The full id is unique in the system.
|
||||
*
|
||||
* @return string|null null is returned when the fullId can't be constructed
|
||||
* @return string
|
||||
* @since 9.0.0
|
||||
* @throws \UnexpectedValueException If the fullId could not be constructed
|
||||
*/
|
||||
public function getFullId();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue