aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/cache
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-10-27 18:05:40 +0200
committerRobin Appelman <icewind@owncloud.com>2012-10-27 18:08:00 +0200
commit79d0ac21ccc65d12b6643ab525d45977644873e8 (patch)
tree06cc781e79cc70902bbd87f845d84f4d63aec6ac /lib/files/cache
parent56e9ce44c3ac18d6183a8959c690c6e3269bc79e (diff)
downloadnextcloud-server-79d0ac21ccc65d12b6643ab525d45977644873e8.tar.gz
nextcloud-server-79d0ac21ccc65d12b6643ab525d45977644873e8.zip
delete child entries when a folder gets removed from cache
Diffstat (limited to 'lib/files/cache')
-rw-r--r--lib/files/cache/cache.php12
-rw-r--r--lib/files/cache/scanner.php16
2 files changed, 25 insertions, 3 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 734890329ae..cba48e4dbea 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -231,9 +231,15 @@ class Cache {
* @param string $file
*/
public function remove($file) {
- $pathHash = md5($file);
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
- $query->execute(array($this->storageId, $pathHash));
+ $entry = $this->get($file);
+ if ($entry['mimetype'] === 'httpd/unix-directory') {
+ $children = $this->getFolderContents($file);
+ foreach($children as $child){
+ $this->remove($child['path']);
+ }
+ }
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?');
+ $query->execute(array($entry['fileid']));
}
/**
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index 0adde1d354d..7062888d74a 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -107,4 +107,20 @@ class Scanner {
}
return $size;
}
+
+ /**
+ * update the folder size and the size of all parent folders
+ *
+ * @param $path
+ */
+ public function correctFolderSize($path) {
+ $this->cache->calculateFolderSize($path);
+ if ($path !== '') {
+ $parent = dirname($path);
+ if ($parent === '.') {
+ $parent = '';
+ }
+ $this->correctFolderSize($parent);
+ }
+ }
}