[Pkg-owncloud-commits] [owncloud] 172/199: Updates per comments on PR:
David Prévot
taffit at moszumanska.debian.org
Sun Jun 1 18:53:23 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 16ae63bdfd8556dceb251fd284dc97d330ca8092
Author: ringmaster <epithet at gmail.com>
Date: Fri May 30 09:42:41 2014 -0400
Updates per comments on PR:
* Use "filesystem_cache_readonly" config setting, update comment in config.sample
* Use $this->cacheActive to cache config setting
* Add public Scanner::setCacheActive() to set $cacheActive programmatically
---
config/config.sample.php | 4 ++--
lib/private/files/cache/scanner.php | 26 ++++++++++++++++++++------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/config/config.sample.php b/config/config.sample.php
index 8fb782e..e2b4c9b 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -293,7 +293,7 @@ $CONFIG = array(
*/
'filesystem_check_changes' => 1,
-/* specifies whether changes in the filesystem outside of owncloud affect cached data about those files */
-'filesystem_check_enable' => 1,
+/* If true, prevent owncloud from changing the cache due to changes in the filesystem for all storage */
+'filesystem_cache_readonly' => false,
);
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index d4942d7..875d941 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -44,6 +44,11 @@ class Scanner extends BasicEmitter {
*/
private $permissionsCache;
+ /**
+ * @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache
+ */
+ protected $cacheActive;
+
const SCAN_RECURSIVE = true;
const SCAN_SHALLOW = false;
@@ -55,6 +60,7 @@ class Scanner extends BasicEmitter {
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
$this->permissionsCache = $storage->getPermissionsCache();
+ $this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false);
}
/**
@@ -139,7 +145,7 @@ class Scanner extends BasicEmitter {
}
$parentCacheData = $this->cache->get($parent);
\OC_Hook::emit('Scanner', 'updateCache', array('file' => $file, 'data' => $data));
- if(Config::getSystemValue('filesystem_check_enable', true)) {
+ if($this->cacheActive) {
$this->cache->update($parentCacheData['fileid'], array(
'etag' => $this->storage->getETag($parent),
));
@@ -161,7 +167,7 @@ class Scanner extends BasicEmitter {
}
if (!empty($newData)) {
\OC_Hook::emit('Scanner', 'addToCache', array('file' => $file, 'data' => $newData));
- if(Config::getSystemValue('filesystem_check_enable', true)) {
+ if(!Config::getSystemValue('filesystem_cache_readonly', false)) {
$data['fileid'] = $this->cache->put($file, $newData);
}
$this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId));
@@ -169,7 +175,7 @@ class Scanner extends BasicEmitter {
}
} else {
\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file));
- if(Config::getSystemValue('filesystem_check_enable', true)) {
+ if($this->cacheActive) {
$this->cache->remove($file);
}
}
@@ -255,7 +261,7 @@ class Scanner extends BasicEmitter {
foreach ($removedChildren as $childName) {
$child = ($path) ? $path . '/' . $childName : $childName;
\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child));
- if(Config::getSystemValue('filesystem_check_enable', true)) {
+ if($this->cacheActive) {
$this->cache->remove($child);
}
}
@@ -278,7 +284,7 @@ class Scanner extends BasicEmitter {
}
$newData = array('size' => $size);
\OC_Hook::emit('Scanner', 'addToCache', array('file' => $child, 'data' => $newData));
- if(Config::getSystemValue('filesystem_check_enable', true)) {
+ if($this->cacheActive) {
$this->cache->put($path, $newData);
}
}
@@ -308,10 +314,18 @@ class Scanner extends BasicEmitter {
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
- if(Config::getSystemValue('filesystem_check_enable', true)) {
+ if($this->cacheActive) {
$this->cache->correctFolderSize($path);
}
$lastPath = $path;
}
}
+
+ /**
+ * Set whether the cache is affected by scan operations
+ * @param boolean $active The active state of the cache
+ */
+ public function setCacheActive($active) {
+ $this->cacheActive = $active;
+ }
}
--
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