diff options
author | Robin Appelman <robin@icewind.nl> | 2018-08-16 19:16:24 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-08-16 19:54:42 +0200 |
commit | 3155c1bd9a40cf0b77e392cf7bc9fad353c820ce (patch) | |
tree | 646f0832de5ca0ff3d1e4b4e1ee15f8c0085e07c /apps/files_sharing/lib/SharedMount.php | |
parent | f7ae235372ee5647003c407dff7eca83cb7a1322 (diff) | |
download | nextcloud-server-3155c1bd9a40cf0b77e392cf7bc9fad353c820ce.tar.gz nextcloud-server-3155c1bd9a40cf0b77e392cf7bc9fad353c820ce.zip |
more efficient unique share target generation
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_sharing/lib/SharedMount.php')
-rw-r--r-- | apps/files_sharing/lib/SharedMount.php | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 1f5b7eaa13e..3dab99115ba 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -135,20 +135,16 @@ class SharedMount extends MountPoint implements MoveableMount { $name = $pathinfo['filename']; $dir = $pathinfo['dirname']; - // Helper function to find existing mount points - $mountpointExists = function ($path) use ($mountpoints) { - foreach ($mountpoints as $mountpoint) { - if ($mountpoint->getShare()->getTarget() === $path) { - return true; - } - } - return false; - }; - $i = 2; - while ($view->file_exists($path) || $mountpointExists($path)) { + $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; + while ($view->file_exists($path) || isset($mountpoints[$absolutePath])) { $path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext); + $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; + var_dump($absolutePath); $i++; + if ($i > 10) { + return $path; + } } return $path; |