re-use view instances for shared storages
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
a8019c357c
commit
0f84994e73
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
namespace OCA\Files_Sharing;
|
namespace OCA\Files_Sharing;
|
||||||
|
|
||||||
|
use OC\Files\View;
|
||||||
use OCP\Files\Config\IMountProvider;
|
use OCP\Files\Config\IMountProvider;
|
||||||
use OCP\Files\Storage\IStorageFactory;
|
use OCP\Files\Storage\IStorageFactory;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
@ -81,19 +82,29 @@ class MountProvider implements IMountProvider {
|
||||||
$superShares = $this->buildSuperShares($shares, $user);
|
$superShares = $this->buildSuperShares($shares, $user);
|
||||||
|
|
||||||
$mounts = [];
|
$mounts = [];
|
||||||
|
$view = new View('/' . $user->getUID() . '/files');
|
||||||
|
$ownerViews = [];
|
||||||
foreach ($superShares as $share) {
|
foreach ($superShares as $share) {
|
||||||
try {
|
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(
|
$mount = new SharedMount(
|
||||||
'\OCA\Files_Sharing\SharedStorage',
|
'\OCA\Files_Sharing\SharedStorage',
|
||||||
$mounts,
|
$mounts,
|
||||||
[
|
[
|
||||||
'user' => $user->getUID(),
|
'user' => $user->getUID(),
|
||||||
// parent share
|
// parent share
|
||||||
'superShare' => $share[0],
|
'superShare' => $parentShare,
|
||||||
// children/component of the superShare
|
// children/component of the superShare
|
||||||
'groupedShares' => $share[1],
|
'groupedShares' => $share[1],
|
||||||
|
'ownerView' => $ownerViews[$owner]
|
||||||
],
|
],
|
||||||
$storageFactory
|
$storageFactory,
|
||||||
|
$view
|
||||||
);
|
);
|
||||||
$mounts[$mount->getMountPoint()] = $mount;
|
$mounts[$mount->getMountPoint()] = $mount;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -60,19 +60,19 @@ class SharedMount extends MountPoint implements MoveableMount {
|
||||||
/**
|
/**
|
||||||
* @param string $storage
|
* @param string $storage
|
||||||
* @param SharedMount[] $mountpoints
|
* @param SharedMount[] $mountpoints
|
||||||
* @param array|null $arguments
|
* @param array $arguments
|
||||||
* @param \OCP\Files\Storage\IStorageFactory $loader
|
* @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->user = $arguments['user'];
|
||||||
$this->recipientView = new View('/' . $this->user . '/files');
|
$this->recipientView = $recipientView;
|
||||||
|
|
||||||
$this->superShare = $arguments['superShare'];
|
$this->superShare = $arguments['superShare'];
|
||||||
$this->groupedShares = $arguments['groupedShares'];
|
$this->groupedShares = $arguments['groupedShares'];
|
||||||
|
|
||||||
$newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints);
|
$newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints);
|
||||||
$absMountPoint = '/' . $this->user . '/files' . $newMountPoint;
|
$absMountPoint = '/' . $this->user . '/files' . $newMountPoint;
|
||||||
$arguments['ownerView'] = new View('/' . $this->superShare->getShareOwner() . '/files');
|
|
||||||
parent::__construct($storage, $absMountPoint, $arguments, $loader);
|
parent::__construct($storage, $absMountPoint, $arguments, $loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue