diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-10-27 18:05:40 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-10-27 18:08:00 +0200 |
commit | 79d0ac21ccc65d12b6643ab525d45977644873e8 (patch) | |
tree | 06cc781e79cc70902bbd87f845d84f4d63aec6ac /lib/files/cache | |
parent | 56e9ce44c3ac18d6183a8959c690c6e3269bc79e (diff) | |
download | nextcloud-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.php | 12 | ||||
-rw-r--r-- | lib/files/cache/scanner.php | 16 |
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); + } + } } |