Merge pull request #483 from owncloud/archive_sizes

stop increasing folder sizes once we hit a non folder
This commit is contained in:
Thomas Müller 2012-11-22 01:56:08 -08:00
commit 54356636e4
2 changed files with 20 additions and 7 deletions

View File

@ -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) {

View File

@ -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;
}
}
}
}