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
Next Next commit
re-use view instances for shared storages
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 16, 2018
commit b79f338e71c37689e39c95633a92e1ed8ed79db7
15 changes: 13 additions & 2 deletions 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\Files\View;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
use OCP\IConfig;
Expand Down Expand Up @@ -84,19 +85,29 @@ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
$superShares = $this->buildSuperShares($shares, $user);

$mounts = [];
$view = new View('/' . $user->getUID() . '/files');
$ownerViews = [];
foreach ($superShares as $share) {
try {
/** @var \OCP\Share\IShare $parentShare */
$parentShare = $share[0];
$owner = $parentShare->getShareOwner();
if (!isset($ownerViews[$owner])) {
$ownerViews[$owner] = new View('/' . $parentShare->getShareOwner() . '/files');
}
$mount = new SharedMount(
'\OCA\Files_Sharing\SharedStorage',
$mounts,
[
'user' => $user->getUID(),
// parent share
'superShare' => $share[0],
'superShare' => $parentShare,
// children/component of the superShare
'groupedShares' => $share[1],
'ownerView' => $ownerViews[$owner]
],
$storageFactory
$storageFactory,
$view
);
$mounts[$mount->getMountPoint()] = $mount;
} catch (\Exception $e) {
Expand Down
8 changes: 4 additions & 4 deletions apps/files_sharing/lib/SharedMount.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ class SharedMount extends MountPoint implements MoveableMount {
/**
* @param string $storage
* @param SharedMount[] $mountpoints
* @param array|null $arguments
* @param array $arguments
* @param \OCP\Files\Storage\IStorageFactory $loader
* @param View $recipientView
*/
public function __construct($storage, array $mountpoints, $arguments = null, $loader = null) {
public function __construct($storage, array $mountpoints, $arguments, $loader, $recipientView) {
$this->user = $arguments['user'];
$this->recipientView = new View('/' . $this->user . '/files');
$this->recipientView = $recipientView;

$this->superShare = $arguments['superShare'];
$this->groupedShares = $arguments['groupedShares'];

$newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints);
$absMountPoint = '/' . $this->user . '/files' . $newMountPoint;
$arguments['ownerView'] = new View('/' . $this->superShare->getShareOwner() . '/files');
parent::__construct($storage, $absMountPoint, $arguments, $loader);
}

Expand Down