diff options
author | Michael Gapczynski <GapczynskiM@gmail.com> | 2012-05-09 17:01:46 -0400 |
---|---|---|
committer | Michael Gapczynski <GapczynskiM@gmail.com> | 2012-05-09 17:01:46 -0400 |
commit | d4636f4b86ada6444ba35346717f77236b99cf2a (patch) | |
tree | 950b01a109a5f5d03f591e5cf8bd1cc118c4a51d /apps | |
parent | 2e826fa82a8a0ad12b411ca264b77ee29d44f77d (diff) | |
download | nextcloud-server-d4636f4b86ada6444ba35346717f77236b99cf2a.tar.gz nextcloud-server-d4636f4b86ada6444ba35346717f77236b99cf2a.zip |
Fix renaming of shared files if target already exists, bug fix for oc-81
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/files_sharing/lib_share.php | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index ecf82abb31e..3bcc2b562e5 100755 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -78,7 +78,9 @@ class OC_Share { // Check if the target already exists for the user, if it does append a number to the name $sharedFolder = '/'.$uid.'/files/Shared'; $target = $sharedFolder."/".basename($source); - if (self::getSource($target)) { + $checkTarget = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE target = ? AND uid_shared_with ".self::getUsersAndGroups($uid, false)." LIMIT 1"); + $result = $checkTarget->execute(array($target))->fetchAll(); + if (count($result) > 0) { if ($pos = strrpos($target, ".")) { $name = substr($target, 0, $pos); $ext = substr($target, $pos); @@ -87,12 +89,11 @@ class OC_Share { $ext = ""; } $counter = 1; - while ($checkTarget !== false) { - $newTarget = $name."_".$counter.$ext; - $checkTarget = self::getSource($newTarget); + while (count($result) > 0) { + $target = $name."_".$counter.$ext; + $result = $checkTarget->execute(array($target))->fetchAll(); $counter++; } - $target = $newTarget; } if (isset($gid)) { $uid = $uid."@".$gid; |