summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorringmaster <epithet@gmail.com>2014-05-30 09:42:41 -0400
committerringmaster <epithet@gmail.com>2014-05-30 09:42:41 -0400
commit16ae63bdfd8556dceb251fd284dc97d330ca8092 (patch)
treecd5378e877c3908f11f28b459fcea083b1e17502
parentf79948f519f5532f95fd744b8ba28329cc45b022 (diff)
downloadnextcloud-server-16ae63bdfd8556dceb251fd284dc97d330ca8092.tar.gz
nextcloud-server-16ae63bdfd8556dceb251fd284dc97d330ca8092.zip
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
-rwxr-xr-xconfig/config.sample.php4
-rw-r--r--lib/private/files/cache/scanner.php26
2 files changed, 22 insertions, 8 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index 8fb782e7cf4..e2b4c9b31ab 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 d4942d7dc2e..875d941fb77 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;
+ }
}