stop increasing folder sizes once we hit a non folder
fixes #234 Conflicts: lib/filecache.php
This commit is contained in:
parent
f849dd0693
commit
3e20032a32
|
@ -354,12 +354,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);
|
||||
$query->execute(array($sizeDiff, $id));
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -514,21 +527,21 @@ class OC_FileCache{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the real path and the root of a shared file
|
||||
* @param string $path
|
||||
* @return array with the path and the root of the give file
|
||||
/**
|
||||
* get the real path and the root of a shared file
|
||||
* @param string $path
|
||||
* @return array with the path and the root of the give file
|
||||
*/
|
||||
private static function getSourcePathOfSharedFile($path, $root) {
|
||||
if ( OC_App::isEnabled('files_sharing')) {
|
||||
$fullPath = OC_Filesystem::normalizePath($root.'/'.$path);
|
||||
$sharedPos = strpos($fullPath, '/Shared/');
|
||||
if ( $sharedPos !== false && ($source = OC_Files_Sharing_Util::getSourcePath(substr($fullPath, $sharedPos+8))) ) {
|
||||
$source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path));
|
||||
$parts = explode('/', $source, 4);
|
||||
$root = '/'.$parts[1].'/files';
|
||||
if ( $sharedPos !== false && ($source = OC_Files_Sharing_Util::getSourcePath(substr($fullPath, $sharedPos+8))) ) {
|
||||
$source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path));
|
||||
$parts = explode('/', $source, 4);
|
||||
$root = '/'.$parts[1].'/files';
|
||||
$path = '/'.$parts[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array($path, $root);
|
||||
|
|
Loading…
Reference in New Issue