summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Jagszent <daniel@jagszent.de>2016-04-15 17:33:02 +0200
committerDaniel Jagszent <daniel@jagszent.de>2016-04-15 17:56:27 +0200
commit5a0938ad8ed414bd36e1f861f92ed5019bf4926b (patch)
tree4681de09cebd145705e0b9a47d782534e1a09fbb /lib
parent63a385d2b84467552cbc197b2548d7d03f0ba6e6 (diff)
downloadnextcloud-server-5a0938ad8ed414bd36e1f861f92ed5019bf4926b.tar.gz
nextcloud-server-5a0938ad8ed414bd36e1f861f92ed5019bf4926b.zip
Call private cache methods only for `OC\Files\Cache\Cache`
The two implementation detail methods `correctFolderSize` and `calculateFolderSize` should only be called for instances of `OC\Files\Cache\Cache`. This commit adds guarding checks whenever they are called.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/scanner.php2
-rw-r--r--lib/private/files/cache/updater.php16
-rw-r--r--lib/private/files/cache/watcher.php4
-rw-r--r--lib/private/files/cache/wrapper/cachejail.php12
-rw-r--r--lib/private/files/cache/wrapper/cachewrapper.php10
5 files changed, 34 insertions, 10 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 5ca32548fe0..35ec2daa20e 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -469,7 +469,7 @@ class Scanner extends BasicEmitter implements IScanner {
try {
$callback();
\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
- if ($this->cacheActive) {
+ if ($this->cacheActive && $this->cache instanceof Cache) {
$this->cache->correctFolderSize($path);
}
} catch (\OCP\Files\StorageInvalidException $e) {
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index 80ba704883e..20163487ddc 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -123,7 +123,9 @@ class Updater implements IUpdater {
} else {
// scanner didn't provide size info, fallback to full size calculation
$sizeDifference = 0;
- $this->cache->correctFolderSize($path, $data);
+ if ($this->cache instanceof Cache) {
+ $this->cache->correctFolderSize($path, $data);
+ }
}
$this->correctParentStorageMtime($path);
$this->propagator->propagateChange($path, $time, $sizeDifference);
@@ -145,7 +147,9 @@ class Updater implements IUpdater {
}
$this->cache->remove($path);
- $this->cache->correctFolderSize($parent);
+ if ($this->cache instanceof Cache) {
+ $this->cache->correctFolderSize($parent);
+ }
$this->correctParentStorageMtime($path);
$this->propagator->propagateChange($path, time());
}
@@ -187,8 +191,12 @@ class Updater implements IUpdater {
$this->cache->update($fileId, ['mimetype' => $mimeType]);
}
- $sourceCache->correctFolderSize($source);
- $this->cache->correctFolderSize($target);
+ if ($sourceCache instanceof Cache) {
+ $sourceCache->correctFolderSize($source);
+ }
+ if ($this->cache instanceof Cache) {
+ $this->cache->correctFolderSize($target);
+ }
if ($sourceUpdater instanceof Updater) {
$sourceUpdater->correctParentStorageMtime($source);
}
diff --git a/lib/private/files/cache/watcher.php b/lib/private/files/cache/watcher.php
index a00e875a2d4..0cf6caf0c28 100644
--- a/lib/private/files/cache/watcher.php
+++ b/lib/private/files/cache/watcher.php
@@ -106,7 +106,9 @@ class Watcher implements IWatcher {
if ($cachedData['mimetype'] === 'httpd/unix-directory') {
$this->cleanFolder($path);
}
- $this->cache->correctFolderSize($path);
+ if ($this->cache instanceof Cache) {
+ $this->cache->correctFolderSize($path);
+ }
}
/**
diff --git a/lib/private/files/cache/wrapper/cachejail.php b/lib/private/files/cache/wrapper/cachejail.php
index 868e63cdf81..65275bcb798 100644
--- a/lib/private/files/cache/wrapper/cachejail.php
+++ b/lib/private/files/cache/wrapper/cachejail.php
@@ -23,6 +23,7 @@
*/
namespace OC\Files\Cache\Wrapper;
+use OC\Files\Cache\Cache;
/**
* Jail to a subdirectory of the wrapped cache
@@ -233,7 +234,9 @@ class CacheJail extends CacheWrapper {
* @param array $data (optional) meta data of the folder
*/
public function correctFolderSize($path, $data = null) {
- $this->cache->correctFolderSize($this->getSourcePath($path), $data);
+ if ($this->cache instanceof Cache) {
+ $this->cache->correctFolderSize($this->getSourcePath($path), $data);
+ }
}
/**
@@ -244,7 +247,12 @@ class CacheJail extends CacheWrapper {
* @return int
*/
public function calculateFolderSize($path, $entry = null) {
- return $this->cache->calculateFolderSize($this->getSourcePath($path), $entry);
+ if ($this->cache instanceof Cache) {
+ return $this->cache->calculateFolderSize($this->getSourcePath($path), $entry);
+ } else {
+ return 0;
+ }
+
}
/**
diff --git a/lib/private/files/cache/wrapper/cachewrapper.php b/lib/private/files/cache/wrapper/cachewrapper.php
index 8c77e3c340e..a6e6e61b8c7 100644
--- a/lib/private/files/cache/wrapper/cachewrapper.php
+++ b/lib/private/files/cache/wrapper/cachewrapper.php
@@ -240,7 +240,9 @@ class CacheWrapper extends Cache {
* @param array $data (optional) meta data of the folder
*/
public function correctFolderSize($path, $data = null) {
- $this->cache->correctFolderSize($path, $data);
+ if ($this->cache instanceof Cache) {
+ $this->cache->correctFolderSize($path, $data);
+ }
}
/**
@@ -251,7 +253,11 @@ class CacheWrapper extends Cache {
* @return int
*/
public function calculateFolderSize($path, $entry = null) {
- return $this->cache->calculateFolderSize($path, $entry);
+ if ($this->cache instanceof Cache) {
+ return $this->cache->calculateFolderSize($path, $entry);
+ } else {
+ return 0;
+ }
}
/**