diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-03-30 17:03:04 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2017-04-07 15:43:59 +0200 |
commit | 3323d01db1eda016f6e4665ae094c85903a83856 (patch) | |
tree | 8845984a62b5bd0d7b27bdbcdc7325c9dc3ee6de /lib/private/Share20 | |
parent | 676a4c781a5ff16ea34259c2958521596efc89b1 (diff) | |
download | nextcloud-server-3323d01db1eda016f6e4665ae094c85903a83856.tar.gz nextcloud-server-3323d01db1eda016f6e4665ae094c85903a83856.zip |
update unit tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Share20')
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 71 |
2 files changed, 29 insertions, 44 deletions
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 - } } } |