[Pkg-owncloud-commits] [owncloud] 111/205: fix etag propagation for single file shares
David Prévot
taffit at moszumanska.debian.org
Thu Jul 2 17:37:01 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 c87ab6508114e1c63f6f09564d2900398fd07333
Author: Robin Appelman <icewind at owncloud.com>
Date: Tue Jun 23 14:52:31 2015 +0200
fix etag propagation for single file shares
---
.../lib/propagation/changewatcher.php | 13 ++++++++-
.../lib/propagation/propagationmanager.php | 5 ++--
.../lib/propagation/recipientpropagator.php | 31 +++++++++++++++-------
3 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/apps/files_sharing/lib/propagation/changewatcher.php b/apps/files_sharing/lib/propagation/changewatcher.php
index 483f436..4c6e9f8 100644
--- a/apps/files_sharing/lib/propagation/changewatcher.php
+++ b/apps/files_sharing/lib/propagation/changewatcher.php
@@ -25,10 +25,17 @@ class ChangeWatcher {
private $baseView;
/**
+ * @var RecipientPropagator
+ */
+ private $recipientPropagator;
+
+ /**
* @param \OC\Files\View $baseView the view for the logged in user
+ * @param RecipientPropagator $recipientPropagator
*/
- public function __construct(View $baseView) {
+ public function __construct(View $baseView, RecipientPropagator $recipientPropagator) {
$this->baseView = $baseView;
+ $this->recipientPropagator = $recipientPropagator;
}
@@ -39,6 +46,10 @@ class ChangeWatcher {
if ($mount instanceof SharedMount) {
$this->propagateForOwner($mount->getShare(), $mount->getInternalPath($fullPath), $mount->getOwnerPropagator());
}
+ $info = $this->baseView->getFileInfo($path);
+ if ($info) {
+ $this->recipientPropagator->propagateById($info->getId());
+ }
}
public function renameHook($params) {
diff --git a/apps/files_sharing/lib/propagation/propagationmanager.php b/apps/files_sharing/lib/propagation/propagationmanager.php
index fa073be..227da7c 100644
--- a/apps/files_sharing/lib/propagation/propagationmanager.php
+++ b/apps/files_sharing/lib/propagation/propagationmanager.php
@@ -75,7 +75,7 @@ class PropagationManager {
if (isset($this->sharePropagators[$user])) {
return $this->sharePropagators[$user];
}
- $this->sharePropagators[$user] = new RecipientPropagator($user, $this->getChangePropagator($user), $this->config);
+ $this->sharePropagators[$user] = new RecipientPropagator($user, $this->getChangePropagator($user), $this->config, $this);
return $this->sharePropagators[$user];
}
@@ -101,7 +101,8 @@ class PropagationManager {
if (!$user) {
return;
}
- $watcher = new ChangeWatcher(Filesystem::getView());
+ $recipientPropagator = $this->getSharePropagator($user->getUID());
+ $watcher = new ChangeWatcher(Filesystem::getView(), $recipientPropagator);
// for marking shares owned by the active user as dirty when a file inside them changes
$this->listenToOwnerChanges($user->getUID(), $user->getUID());
diff --git a/apps/files_sharing/lib/propagation/recipientpropagator.php b/apps/files_sharing/lib/propagation/recipientpropagator.php
index 5b7651f..c426128 100644
--- a/apps/files_sharing/lib/propagation/recipientpropagator.php
+++ b/apps/files_sharing/lib/propagation/recipientpropagator.php
@@ -32,16 +32,23 @@ class RecipientPropagator {
protected $config;
/**
+ * @var PropagationManager
+ */
+ private $manager;
+
+ /**
* @param string $userId 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
*/
- public function __construct($userId, $changePropagator, $config) {
+ public function __construct($userId, $changePropagator, $config, PropagationManager $manager) {
$this->userId = $userId;
$this->changePropagator = $changePropagator;
$this->config = $config;
+ $this->manager = $manager;
}
/**
@@ -101,18 +108,24 @@ class RecipientPropagator {
*/
public function attachToPropagator(ChangePropagator $propagator, $owner) {
$propagator->listen('\OC\Files', 'propagate', function ($path, $entry) use ($owner) {
- $shares = Share::getAllSharesForFileId($entry['fileid']);
- foreach ($shares as $share) {
- // propagate down the share tree
- $this->markDirty($share, microtime(true));
+ $this->propagateById($entry['fileid']);
+ });
+ }
- // propagate up the share tree
- $user = $share['uid_owner'];
+ public function propagateById($id) {
+ $shares = Share::getAllSharesForFileId($id);
+ foreach ($shares as $share) {
+ // propagate down the share tree
+ $this->markDirty($share, microtime(true));
+
+ // propagate up the share tree
+ $user = $share['uid_owner'];
+ if($user !== $this->userId) {
$view = new View('/' . $user . '/files');
$path = $view->getPath($share['file_source']);
- $watcher = new ChangeWatcher($view);
+ $watcher = new ChangeWatcher($view, $this->manager->getSharePropagator($user));
$watcher->writeHook(['path' => $path]);
}
- });
+ }
}
}
--
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