Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cache parent exists status during share setup
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 16, 2018
commit 67f3d6f0a6b87290cba0d6cf1f5e03e4e97e1f78
4 changes: 0 additions & 4 deletions apps/files_sharing/lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ public static function generateUniqueTarget($path, $excludeList, $view) {
return $path;
}

public static function isUsingShareFolder() {
return \OC::$server->getConfig()->getSystemValue('share_folder', '/') !== '/';
}

/**
* get default share folder
*
Expand Down
5 changes: 4 additions & 1 deletion apps/files_sharing/lib/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,6 +89,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
$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 */
Expand All @@ -109,7 +111,8 @@ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
'sharingDisabledForUser' => $sharingDisabledForUser
],
$storageFactory,
$view
$view,
$foldersExistCache
);
$mounts[$mount->getMountPoint()] = $mount;
} catch (\Exception $e) {
Expand Down
18 changes: 13 additions & 5 deletions apps/files_sharing/lib/SharedMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -84,12 +86,18 @@ public function __construct($storage, array $mountpoints, $arguments, $loader, $
* @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);
}

Expand Down