From 74611801dd525b6b30580061d1919c864330fc56 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 16 Nov 2012 17:41:38 +0100 Subject: [PATCH 1/3] typo --- lib/filecache.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/filecache.php b/lib/filecache.php index 4a7dbd0250..1a6100481a 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -362,9 +362,9 @@ class OC_FileCache{ /** * recursively scan the filesystem and fill the cache * @param string $path - * @param OC_EventSource $enventSource (optional) - * @param int count (optional) - * @param string root (optional) + * @param OC_EventSource $eventSource (optional) + * @param int $count (optional) + * @param string $root (optional) */ public static function scan($path, $eventSource=false,&$count=0, $root=false) { if($eventSource) { From 8fe69dfac69351a10e587fb845a00d3dcdf2e82c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 16 Nov 2012 17:52:52 +0100 Subject: [PATCH 2/3] also return fileid in OC_Filecache::get --- lib/filecache/cached.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/filecache/cached.php b/lib/filecache/cached.php index 7458322fb1..5e0a00746b 100644 --- a/lib/filecache/cached.php +++ b/lib/filecache/cached.php @@ -18,7 +18,7 @@ class OC_FileCache_Cached{ $root=OC_Filesystem::getRoot(); } $path=$root.$path; - $stmt=OC_DB::prepare('SELECT `path`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `path_hash`=?'); + $stmt=OC_DB::prepare('SELECT `id`, `path`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `path_hash`=?'); if ( ! OC_DB::isError($stmt) ) { $result=$stmt->execute(array(md5($path))); if ( ! OC_DB::isError($result) ) { @@ -78,4 +78,4 @@ class OC_FileCache_Cached{ return false; } } -} \ No newline at end of file +} From 1007013833486dbf72b35ba8167944bd495da05b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 16 Nov 2012 17:54:58 +0100 Subject: [PATCH 3/3] stop increasing folder sizes once we hit a non folder fixes #234 --- lib/filecache.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/filecache.php b/lib/filecache.php index 1a6100481a..a74d7cbc39 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -350,12 +350,25 @@ class OC_FileCache{ */ public static function increaseSize($path, $sizeDiff, $root=false) { if($sizeDiff==0) return; - $id=self::getId($path, $root); + $item = OC_FileCache_Cached::get($path); + //stop walking up the filetree if we hit a non-folder + if($item['mimetype'] !== 'httpd/unix-directory'){ + return; + } + $id = $item['id']; while($id!=-1) {//walk up the filetree increasing the size of all parent folders $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?'); $query->execute(array($sizeDiff, $id)); - $id=self::getParentId($path); + if($path == '' or $path =='/'){ + return; + } $path=dirname($path); + $parent = OC_FileCache_Cached::get($path); + $id = $parent['id']; + //stop walking up the filetree if we hit a non-folder + if($parent['mimetype'] !== 'httpd/unix-directory'){ + return; + } } }