summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Douma <rullzer@users.noreply.github.com>2015-07-28 13:06:25 +0200
committerRoeland Douma <rullzer@users.noreply.github.com>2015-07-28 13:06:25 +0200
commit73169b0edbc1086d2a287c26640e2a2428449971 (patch)
tree592282ffb1f48edbdacc6e4c18fc2124cfa315f4 /lib
parent4076f84f888a16e00dc6978a47141b8d8cac8413 (diff)
parente35b97e4c5dd87dd03e409db0e20cd6c844d966b (diff)
downloadnextcloud-server-73169b0edbc1086d2a287c26640e2a2428449971.tar.gz
nextcloud-server-73169b0edbc1086d2a287c26640e2a2428449971.zip
Merge pull request #17195 from rullzer/no_multiple_remote_shares_of_same_file
Remote shares should be uique
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share/share.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index c0285125234..40fcc59f219 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -782,6 +782,19 @@ class Share extends Constants {
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::ERROR);
throw new \Exception($message_t);
} else if ($shareType === self::SHARE_TYPE_REMOTE) {
+
+ /*
+ * Check if file is not already shared with the remote user
+ */
+ if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_REMOTE,
+ $shareWith, $uidOwner, self::FORMAT_NONE, null, 1, true, true)) {
+ $message = 'Sharing %s failed, because this item is already shared with %s';
+ $message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
+ \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
+ throw new \Exception($message_t);
+ }
+
+
$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
\OCP\Security\ISecureRandom::CHAR_DIGITS);