summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-08-16 21:05:01 +0200
committerRobin Appelman <robin@icewind.nl>2018-08-27 16:25:51 +0200
commit6dae2b92508696c6b47216099abdd3f3fcd8497e (patch)
treea6e7a65bf558d7bbe14109fe8369a4eb5746054c
parente3b9e9e57c9aab9175b381048597d0a92abcd118 (diff)
downloadnextcloud-server-6dae2b92508696c6b47216099abdd3f3fcd8497e.tar.gz
nextcloud-server-6dae2b92508696c6b47216099abdd3f3fcd8497e.zip
cache parent exists status during share setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--apps/files_sharing/lib/Helper.php4
-rw-r--r--apps/files_sharing/lib/MountProvider.php5
-rw-r--r--apps/files_sharing/lib/SharedMount.php18
3 files changed, 17 insertions, 10 deletions
diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php
index 465a55a0052..c8f46fa8132 100644
--- a/apps/files_sharing/lib/Helper.php
+++ b/apps/files_sharing/lib/Helper.php
@@ -237,10 +237,6 @@ class Helper {
return $path;
}
- public static function isUsingShareFolder() {
- return \OC::$server->getConfig()->getSystemValue('share_folder', '/') !== '/';
- }
-
/**
* get default share folder
*
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php
index c4fa6edc876..5623f18d662 100644
--- a/apps/files_sharing/lib/MountProvider.php
+++ b/apps/files_sharing/lib/MountProvider.php
@@ -27,6 +27,7 @@
namespace OCA\Files_Sharing;
+use OC\Cache\CappedMemoryCache;
use OC\Files\View;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
@@ -87,6 +88,7 @@ class MountProvider implements IMountProvider {
$view = new View('/' . $user->getUID() . '/files');
$ownerViews = [];
$sharingDisabledForUser = $this->shareManager->sharingDisabledForUser($user->getUID());
+ $foldersExistCache = new CappedMemoryCache();
foreach ($superShares as $share) {
try {
/** @var \OCP\Share\IShare $parentShare */
@@ -108,7 +110,8 @@ class MountProvider implements IMountProvider {
'sharingDisabledForUser' => $sharingDisabledForUser
],
$storageFactory,
- $view
+ $view,
+ $foldersExistCache
);
$mounts[$mount->getMountPoint()] = $mount;
} catch (\Exception $e) {
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php
index dacc78edac3..4b38698f81d 100644
--- a/apps/files_sharing/lib/SharedMount.php
+++ b/apps/files_sharing/lib/SharedMount.php
@@ -28,10 +28,12 @@
namespace OCA\Files_Sharing;
+use OC\Cache\CappedMemoryCache;
use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
use OC\Files\Mount\MoveableMount;
use OC\Files\View;
+use OCP\Files\Storage\IStorageFactory;
/**
* Shared mount points can be moved by the user
@@ -62,17 +64,17 @@ class SharedMount extends MountPoint implements MoveableMount {
* @param string $storage
* @param SharedMount[] $mountpoints
* @param array $arguments
- * @param \OCP\Files\Storage\IStorageFactory $loader
+ * @param IStorageFactory $loader
* @param View $recipientView
*/
- public function __construct($storage, array $mountpoints, $arguments, $loader, $recipientView) {
+ public function __construct($storage, array $mountpoints, $arguments, IStorageFactory $loader, View $recipientView, CappedMemoryCache $folderExistCache) {
$this->user = $arguments['user'];
$this->recipientView = $recipientView;
$this->superShare = $arguments['superShare'];
$this->groupedShares = $arguments['groupedShares'];
- $newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints);
+ $newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints, $folderExistCache);
$absMountPoint = '/' . $this->user . '/files' . $newMountPoint;
parent::__construct($storage, $absMountPoint, $arguments, $loader);
}
@@ -84,12 +86,18 @@ class SharedMount extends MountPoint implements MoveableMount {
* @param SharedMount[] $mountpoints
* @return string
*/
- private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints) {
+ private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints, CappedMemoryCache $folderExistCache) {
$mountPoint = basename($share->getTarget());
$parent = dirname($share->getTarget());
- if (Helper::isUsingShareFolder() && !$this->recipientView->is_dir($parent)) {
+ if ($folderExistCache->hasKey($parent)) {
+ $parentExists = $folderExistCache->get($parent);
+ } else {
+ $parentExists = $this->recipientView->is_dir($parent);
+ $folderExistCache->set($parent, $parentExists);
+ }
+ if (!$parentExists) {
$parent = Helper::getShareFolder($this->recipientView);
}