summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2012-11-22 01:56:08 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2012-11-22 01:56:08 -0800
commit54356636e41d95abd9cb37fe628c9e8b02ca2166 (patch)
treeaf8ad1fb132538103daf7443e65d90bb9d918499
parent3a5f5e127c4fa151a227b9927f037925a6c9a17f (diff)
parent1007013833486dbf72b35ba8167944bd495da05b (diff)
downloadnextcloud-server-54356636e41d95abd9cb37fe628c9e8b02ca2166.tar.gz
nextcloud-server-54356636e41d95abd9cb37fe628c9e8b02ca2166.zip
Merge pull request #483 from owncloud/archive_sizes
stop increasing folder sizes once we hit a non folder
-rw-r--r--lib/filecache.php23
-rw-r--r--lib/filecache/cached.php4
2 files changed, 20 insertions, 7 deletions
diff --git a/lib/filecache.php b/lib/filecache.php
index f1d6a823c4c..2479d29e329 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 7458322fb14..5e0a00746b9 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
+}