Merge pull request #483 from owncloud/archive_sizes
stop increasing folder sizes once we hit a non folder
This commit is contained in:
commit
54356636e4
|
@ -352,21 +352,34 @@ class OC_FileCache{
|
||||||
*/
|
*/
|
||||||
public static function increaseSize($path, $sizeDiff, $root=false) {
|
public static function increaseSize($path, $sizeDiff, $root=false) {
|
||||||
if($sizeDiff==0) return;
|
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
|
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=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?');
|
||||||
$query->execute(array($sizeDiff, $id));
|
$query->execute(array($sizeDiff, $id));
|
||||||
$id=self::getParentId($path);
|
if($path == '' or $path =='/'){
|
||||||
|
return;
|
||||||
|
}
|
||||||
$path=dirname($path);
|
$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
|
* recursively scan the filesystem and fill the cache
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param OC_EventSource $enventSource (optional)
|
* @param OC_EventSource $eventSource (optional)
|
||||||
* @param int count (optional)
|
* @param int $count (optional)
|
||||||
* @param string root (optional)
|
* @param string $root (optional)
|
||||||
*/
|
*/
|
||||||
public static function scan($path, $eventSource=false,&$count=0, $root=false) {
|
public static function scan($path, $eventSource=false,&$count=0, $root=false) {
|
||||||
if($eventSource) {
|
if($eventSource) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ class OC_FileCache_Cached{
|
||||||
$root=OC_Filesystem::getRoot();
|
$root=OC_Filesystem::getRoot();
|
||||||
}
|
}
|
||||||
$path=$root.$path;
|
$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) ) {
|
if ( ! OC_DB::isError($stmt) ) {
|
||||||
$result=$stmt->execute(array(md5($path)));
|
$result=$stmt->execute(array(md5($path)));
|
||||||
if ( ! OC_DB::isError($result) ) {
|
if ( ! OC_DB::isError($result) ) {
|
||||||
|
|
Loading…
Reference in New Issue