diff --git a/lib/filecache.php b/lib/filecache.php index f1d6a823c4..2479d29e32 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -352,21 +352,34 @@ 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; + } } } /** * 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) { 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 +}