From 3323d01db1eda016f6e4665ae094c85903a83856 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 30 Mar 2017 17:03:04 +0200 Subject: update unit tests Signed-off-by: Bjoern Schiessle --- lib/private/Share20/DefaultShareProvider.php | 2 +- lib/private/Share20/Manager.php | 71 +++++++++++----------------- 2 files changed, 29 insertions(+), 44 deletions(-) (limited to 'lib/private/Share20') diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 0d02123e001..bf8bcc9c6d9 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -116,7 +116,7 @@ class DefaultShareProvider implements IShareProvider { //If a password is set store it if ($share->getPassword() !== null) { - $qb->setValue('share_with', $qb->createNamedParameter($share->getPassword())); + $qb->setValue('password', $qb->createNamedParameter($share->getPassword())); } //If an expiration date is set store it diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 0dade2f7126..292b07d28d5 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -266,8 +266,8 @@ class Manager implements IManager { // Check that read permissions are always set // Link shares are allowed to have no read permissions to allow upload to hidden folders - $noReadPermissionRequired = $share->getShareType() !== \OCP\Share::SHARE_TYPE_LINK - || $share->getShareType() !== \OCP\Share::SHARE_TYPE_EMAIL; + $noReadPermissionRequired = $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK + || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL; if (!$noReadPermissionRequired && ($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) { throw new \InvalidArgumentException('Shares need at least read permissions'); @@ -936,59 +936,49 @@ class Manager implements IManager { * Work around so we don't return expired shares but still follow * proper pagination. */ - if ($shareType === \OCP\Share::SHARE_TYPE_LINK) { - $shares2 = []; - while(true) { - $added = 0; - foreach ($shares as $share) { + $shares2 = []; - $added++; - $shares2[] = $share; + while(true) { + $added = 0; + foreach ($shares as $share) { - if (count($shares2) === $limit) { - break; - } + try { + $this->checkExpireDate($share); + } catch (ShareNotFound $e) { + //Ignore since this basically means the share is deleted + continue; } - if (count($shares2) === $limit) { - break; - } + $added++; + $shares2[] = $share; - // If there was no limit on the select we are done - if ($limit === -1) { + if (count($shares2) === $limit) { break; } + } - $offset += $added; - - // Fetch again $limit shares - $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); + if (count($shares2) === $limit) { + break; + } - // No more shares means we are done - if (empty($shares)) { - break; - } + // If there was no limit on the select we are done + if ($limit === -1) { + break; } - $shares = $shares2; - } + $offset += $added; + // Fetch again $limit shares + $shares = $provider->getSharesBy($userId, $shareType, $path, $reshares, $limit, $offset); - // remove all shares which are already expired - foreach ($shares as $key => $share) { - try { - $this->checkExpireDate($share); - } catch (ShareNotFound $e) { - unset($shares[$key]); - try { - $this->deleteShare($share); - } catch (NotFoundException $e) { - //Ignore since this basically means the share is deleted - } + // No more shares means we are done + if (empty($shares)) { + break; } } + $shares = $shares2; return $shares; } @@ -1011,11 +1001,6 @@ class Manager implements IManager { $this->checkExpireDate($share); } catch (ShareNotFound $e) { unset($shares[$key]); - try { - $this->deleteShare($share); - } catch (NotFoundException $e) { - //Ignore since this basically means the share is deleted - } } } -- cgit v1.2.3