diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-28 10:58:50 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-28 10:58:50 +0200 |
commit | de8c15e1a46e33a20af1bad97a8cf27fced84539 (patch) | |
tree | 36a46b15dcf68d2d5feea06d7b57f4b8701321f5 /lib/private | |
parent | 5fa5f46a88371322fa37e1e34ebc73ccea6c42b1 (diff) | |
parent | 5304afbecb37b841312e35594ef8cba403a4cd8c (diff) | |
download | nextcloud-server-de8c15e1a46e33a20af1bad97a8cf27fced84539.tar.gz nextcloud-server-de8c15e1a46e33a20af1bad97a8cf27fced84539.zip |
Merge pull request #14764 from owncloud/shared-etag-propagate
Propagate etags across shared storages
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/connector/sabre/file.php | 1 | ||||
-rw-r--r-- | lib/private/files/cache/changepropagator.php | 5 | ||||
-rw-r--r-- | lib/private/files/cache/updater.php | 4 | ||||
-rw-r--r-- | lib/private/files/view.php | 4 | ||||
-rw-r--r-- | lib/private/share/share.php | 24 |
5 files changed, 37 insertions, 1 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 100aba13668..8ff5577629d 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -181,6 +181,7 @@ class File extends Node implements IFile { $view = \OC\Files\Filesystem::getView(); if ($view) { $hookPath = $view->getRelativePath($this->fileView->getAbsolutePath($this->path)); + $this->fileView->getUpdater()->propagate($hookPath); if (!$exists) { \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, array( \OC\Files\Filesystem::signal_param_path => $hookPath diff --git a/lib/private/files/cache/changepropagator.php b/lib/private/files/cache/changepropagator.php index 4a860631ae0..9696a82257e 100644 --- a/lib/private/files/cache/changepropagator.php +++ b/lib/private/files/cache/changepropagator.php @@ -22,12 +22,14 @@ namespace OC\Files\Cache; +use OC\Hooks\BasicEmitter; + /** * Propagates changes in etag and mtime up the filesystem tree * * @package OC\Files\Cache */ -class ChangePropagator { +class ChangePropagator extends BasicEmitter { /** * @var string[] */ @@ -75,6 +77,7 @@ class ChangePropagator { $cache = $storage->getCache(); $entry = $cache->get($internalPath); $cache->update($entry['fileid'], array('mtime' => max($time, $entry['mtime']), 'etag' => $storage->getETag($internalPath))); + $this->emit('\OC\Files', 'propagate', [$parent, $entry]); } } } diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index 14aecf01220..66345350168 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -60,6 +60,10 @@ class Updater { $this->enabled = true; } + public function getPropagator() { + return $this->propagator; + } + public function propagate($path, $time = null) { if (Scanner::isPartialFile($path)) { return; diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 162bf568de7..63af2b616cf 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -658,6 +658,10 @@ class View { } elseif ($result) { if ($internalPath1 !== '') { // dont do a cache update for moved mounts $this->updater->rename($path1, $path2); + } else { // only do etag propagation + $this->getUpdater()->getPropagator()->addChange($path1); + $this->getUpdater()->getPropagator()->addChange($path2); + $this->getUpdater()->getPropagator()->propagateChanges(); } if ($this->shouldEmitHooks($path1) and $this->shouldEmitHooks($path2)) { \OC_Hook::emit( diff --git a/lib/private/share/share.php b/lib/private/share/share.php index f1a1fbdd101..617eeeb9d90 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -2530,4 +2530,28 @@ class Share extends Constants { $enforcePassword = $config->getAppValue('core', 'shareapi_enforce_links_password', 'no'); return ($enforcePassword === "yes") ? true : false; } + + /** + * Get all share entries, including non-unique group items + * + * @param string $owner + * @return array + */ + public static function getAllSharesForOwner($owner) { + $query = 'SELECT * FROM `*PREFIX*share` WHERE `uid_owner` = ?'; + $result = \OC::$server->getDatabaseConnection()->executeQuery($query, [$owner]); + return $result->fetchAll(); + } + + /** + * Get all share entries, including non-unique group items for a file + * + * @param int $id + * @return array + */ + public static function getAllSharesForFileId($id) { + $query = 'SELECT * FROM `*PREFIX*share` WHERE `file_source` = ?'; + $result = \OC::$server->getDatabaseConnection()->executeQuery($query, [$id]); + return $result->fetchAll(); + } } |