[Pkg-owncloud-commits] [owncloud] 49/107: fix etag propagation with group reshares
David Prévot
taffit at moszumanska.debian.org
Thu Dec 17 19:40:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 63a2e36816a760365a5375360082cc52e365d0f6
Author: Robin Appelman <icewind at owncloud.com>
Date: Wed Dec 9 13:35:31 2015 +0100
fix etag propagation with group reshares
---
apps/files_sharing/appinfo/application.php | 4 ++-
apps/files_sharing/lib/mountprovider.php | 2 +-
.../lib/propagation/propagationmanager.php | 32 +++++++++++++----
.../lib/propagation/recipientpropagator.php | 40 +++++++++++++++++++---
4 files changed, 65 insertions(+), 13 deletions(-)
diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php
index 9dc0e06..252bba1 100644
--- a/apps/files_sharing/appinfo/application.php
+++ b/apps/files_sharing/appinfo/application.php
@@ -136,7 +136,9 @@ class Application extends App {
$server = $c->query('ServerContainer');
return new PropagationManager(
$server->getUserSession(),
- $server->getConfig()
+ $server->getConfig(),
+ $server->getGroupManager(),
+ $server->getUserManager()
);
});
diff --git a/apps/files_sharing/lib/mountprovider.php b/apps/files_sharing/lib/mountprovider.php
index 458e7f2..d1ec254 100644
--- a/apps/files_sharing/lib/mountprovider.php
+++ b/apps/files_sharing/lib/mountprovider.php
@@ -60,7 +60,7 @@ class MountProvider implements IMountProvider {
*/
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
$shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
- $propagator = $this->propagationManager->getSharePropagator($user->getUID());
+ $propagator = $this->propagationManager->getSharePropagator($user);
$propagator->propagateDirtyMountPoints($shares);
$shares = array_filter($shares, function ($share) {
return $share['permissions'] > 0;
diff --git a/apps/files_sharing/lib/propagation/propagationmanager.php b/apps/files_sharing/lib/propagation/propagationmanager.php
index 6ed70e9..0f24d66 100644
--- a/apps/files_sharing/lib/propagation/propagationmanager.php
+++ b/apps/files_sharing/lib/propagation/propagationmanager.php
@@ -24,6 +24,9 @@ namespace OCA\Files_Sharing\Propagation;
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\IConfig;
+use OCP\IGroupManager;
+use OCP\IUser;
+use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Util;
@@ -56,9 +59,21 @@ class PropagationManager {
*/
private $sharePropagators = [];
- public function __construct(IUserSession $userSession, IConfig $config) {
+ /**
+ * @var IGroupManager
+ */
+ private $groupManager;
+
+ /**
+ * @var IUserManager
+ */
+ private $userManager;
+
+ public function __construct(IUserSession $userSession, IConfig $config, IGroupManager $groupManager, IUserManager $userManager) {
$this->userSession = $userSession;
$this->config = $config;
+ $this->groupManager = $groupManager;
+ $this->userManager = $userManager;
}
/**
@@ -97,15 +112,18 @@ class PropagationManager {
}
/**
- * @param string $user
+ * @param IUser|string $user
* @return \OCA\Files_Sharing\Propagation\RecipientPropagator
*/
public function getSharePropagator($user) {
- if (isset($this->sharePropagators[$user])) {
- return $this->sharePropagators[$user];
+ if (!$user instanceof IUser) {
+ $user = $this->userManager->get($user);
+ }
+ if (isset($this->sharePropagators[$user->getUID()])) {
+ return $this->sharePropagators[$user->getUID()];
}
- $this->sharePropagators[$user] = new RecipientPropagator($user, $this->getChangePropagator($user), $this->config, $this);
- return $this->sharePropagators[$user];
+ $this->sharePropagators[$user->getUID()] = new RecipientPropagator($user, $this->getChangePropagator($user->getUID()), $this->config, $this, $this->groupManager);
+ return $this->sharePropagators[$user->getUID()];
}
/**
@@ -130,7 +148,7 @@ class PropagationManager {
if (!$user) {
return;
}
- $recipientPropagator = $this->getSharePropagator($user->getUID());
+ $recipientPropagator = $this->getSharePropagator($user);
$watcher = new ChangeWatcher(Filesystem::getView(), $recipientPropagator);
// for marking shares owned by the active user as dirty when a file inside them changes
diff --git a/apps/files_sharing/lib/propagation/recipientpropagator.php b/apps/files_sharing/lib/propagation/recipientpropagator.php
index 8e064e2..e71208f 100644
--- a/apps/files_sharing/lib/propagation/recipientpropagator.php
+++ b/apps/files_sharing/lib/propagation/recipientpropagator.php
@@ -25,6 +25,8 @@ namespace OCA\Files_Sharing\Propagation;
use OC\Files\Cache\ChangePropagator;
use OC\Files\View;
use OC\Share\Share;
+use OCP\IGroupManager;
+use OCP\IUser;
/**
* Propagate etags for share recipients
@@ -51,18 +53,31 @@ class RecipientPropagator {
private $manager;
/**
- * @param string $userId current user, must match the propagator's
+ * @var IGroupManager
+ */
+ private $groupManager;
+
+ /**
+ * @var IUser
+ */
+ private $user;
+
+ /**
+ * @param IUser $user current user, must match the propagator's
* user
* @param \OC\Files\Cache\ChangePropagator $changePropagator change propagator
* initialized with a view for $user
* @param \OCP\IConfig $config
* @param PropagationManager $manager
+ * @param IGroupManager $groupManager
*/
- public function __construct($userId, $changePropagator, $config, PropagationManager $manager) {
- $this->userId = $userId;
+ public function __construct(IUser $user, $changePropagator, $config, PropagationManager $manager, IGroupManager $groupManager) {
+ $this->userId = $user->getUID();
+ $this->user = $user;
$this->changePropagator = $changePropagator;
$this->config = $config;
$this->manager = $manager;
+ $this->groupManager = $groupManager;
}
/**
@@ -139,7 +154,7 @@ class RecipientPropagator {
$this->markDirty($share, microtime(true));
// propagate up the share tree
- if ($share['share_with'] === $this->userId) {
+ if ($this->isRecipientOfShare($share)) {
$user = $share['uid_owner'];
$view = new View('/' . $user . '/files');
$path = $view->getPath($share['file_source']);
@@ -150,4 +165,21 @@ class RecipientPropagator {
unset($this->propagatingIds[$id]);
}
+
+ /**
+ * Check if the user for this recipient propagator is the recipient of a share
+ *
+ * @param array $share
+ * @return bool
+ */
+ private function isRecipientOfShare($share) {
+ if ($share['share_with'] === $this->userId && $share['share_type'] == \OCP\Share::SHARE_TYPE_USER) { // == since 'share_type' is a string
+ return true;
+ }
+ if ($share['share_type'] == \OCP\Share::SHARE_TYPE_GROUP) {
+ $groups = $this->groupManager->getUserGroupIds($this->user);
+ return in_array($share['share_with'], $groups);
+ }
+ return false;
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list