diff options
Diffstat (limited to 'apps/files_sharing/lib/MountProvider.php')
-rw-r--r-- | apps/files_sharing/lib/MountProvider.php | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index d8f355f2fd3..c71c0e8ddea 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -26,6 +26,7 @@ namespace OCA\Files_Sharing; use OCP\Files\Config\IMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; +use OCP\ILogger; use OCP\IUser; use OCP\Share\IManager; @@ -41,12 +42,19 @@ class MountProvider implements IMountProvider { protected $shareManager; /** + * @var ILogger + */ + protected $logger; + + /** * @param \OCP\IConfig $config * @param IManager $shareManager + * @param ILogger $logger */ - public function __construct(IConfig $config, IManager $shareManager) { + public function __construct(IConfig $config, IManager $shareManager, ILogger $logger) { $this->config = $config; $this->shareManager = $shareManager; + $this->logger = $logger; } @@ -60,22 +68,28 @@ class MountProvider implements IMountProvider { public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1); $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1)); - $shares = array_filter($shares, function (\OCP\Share\IShare $share) { - return $share->getPermissions() > 0; + // filter out excluded shares and group shares that includes self + $shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) { + return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID(); }); $mounts = []; foreach ($shares as $share) { - $mounts[] = new SharedMount( - '\OC\Files\Storage\Shared', - $mounts, - [ - 'user' => $user->getUID(), - 'newShare' => $share, - ], - $storageFactory - ); + try { + $mounts[] = new SharedMount( + '\OC\Files\Storage\Shared', + $mounts, + [ + 'user' => $user->getUID(), + 'newShare' => $share, + ], + $storageFactory + ); + } catch (\Exception $e) { + $this->logger->logException($e); + $this->logger->error('Error while trying to create shared mount'); + } } // array_filter removes the null values from the array |