From 3dfb1628ce6e394a80c03a96da7c837209767e5b Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Tue, 19 Feb 2013 20:42:48 -0500 Subject: [PATCH] Include etags for the root of the shared folder --- apps/files_sharing/lib/cache.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 9655e447875..910c268f011 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -28,10 +28,11 @@ namespace OC\Files\Cache; */ class Shared_Cache extends Cache { + private $storage; private $files = array(); public function __construct($storage) { - + $this->storage = $storage; } /** @@ -64,7 +65,14 @@ class Shared_Cache extends Cache { */ public function get($file) { if ($file == '') { - return \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT); + $data = \OCP\Share::getItemsSharedWith('file', \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT); + $etag = \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_sharing', 'etag'); + if (!isset($etag)) { + $etag = $this->storage->getETag(''); + \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_sharing', 'etag', $etag); + } + $data['etag'] = $etag; + return $data; } else if (is_string($file)) { if ($cache = $this->getSourceCache($file)) { return $cache->get($this->files[$file]); @@ -117,7 +125,9 @@ class Shared_Cache extends Cache { * @return int file id */ public function put($file, array $data) { - if ($cache = $this->getSourceCache($file)) { + if ($file == '' && isset($data['etag'])) { + \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_sharing', 'etag', $etag); + } else if ($cache = $this->getSourceCache($file)) { return $cache->put($this->files[$file], $data); } return false; -- 2.39.5