diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-01 13:46:57 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-09-01 13:46:57 -0400 |
commit | 29d1e8087d3f94a78fc23e1fdd44c139349625b0 (patch) | |
tree | b33043a3a8a4eb3b72993358c092af43fd35c0dc /apps | |
parent | 6d48f3fab8c19b2f2b0986c294d45449e47025ea (diff) | |
download | nextcloud-server-29d1e8087d3f94a78fc23e1fdd44c139349625b0.tar.gz nextcloud-server-29d1e8087d3f94a78fc23e1fdd44c139349625b0.zip |
Implement generateTarget for file sharing backend
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/share/file.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php index b1e3ca8b48c..82744924be3 100644 --- a/apps/files_sharing/lib/share/file.php +++ b/apps/files_sharing/lib/share/file.php @@ -46,9 +46,25 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent { return false; } - public function generateTarget($itemSource, $shareWith, $exclude = null) { - // TODO Make sure target path doesn't exist already - return $itemSource; + public function generateTarget($filePath, $shareWith, $exclude = null) { + $target = $filePath; + if (isset($exclude)) { + if ($pos = strrpos($target, '.')) { + $name = substr($target, 0, $pos); + $ext = substr($target, $pos); + } else { + $name = $filePath; + $ext = ''; + } + $i = 2; + $append = ''; + while (in_array($name.$append.$ext, $exclude)) { + $append = ' ('.$i.')'; + $i++; + } + $target = $name.$append.$ext; + } + return $target; } public function formatItems($items, $format, $parameters = null) { |