move correctFolderSize from Scanner to Cache

This commit is contained in:
Robin Appelman 2012-11-08 18:10:54 +01:00
parent 3f644fe70c
commit 15b8a3f987
4 changed files with 18 additions and 18 deletions

View File

@ -340,6 +340,22 @@ class Cache {
return $result->fetchAll();
}
/**
* update the folder size and the size of all parent folders
*
* @param $path
*/
public function correctFolderSize($path) {
$this->calculateFolderSize($path);
if ($path !== '') {
$parent = dirname($path);
if ($parent === '.') {
$parent = '';
}
$this->correctFolderSize($parent);
}
}
/**
* get the size of a folder and set it in the cache
*

View File

@ -107,20 +107,4 @@ class Scanner {
}
return $size;
}
/**
* update the folder size and the size of all parent folders
*
* @param $path
*/
public function correctFolderSize($path) {
$this->cache->calculateFolderSize($path);
if ($path !== '') {
$parent = dirname($path);
if ($parent === '.') {
$parent = '';
}
$this->correctFolderSize($parent);
}
}
}

View File

@ -50,7 +50,7 @@ class Watcher {
} else {
$this->scanner->scanFile($path);
}
$this->scanner->correctFolderSize($path);
$this->cache->correctFolderSize($path);
}
}

View File

@ -98,7 +98,7 @@ class Scanner extends \UnitTestCase {
$this->assertNotEqual($cachedDataFolder2['size'], -1);
$this->scanner->correctFolderSize('folder');
$this->cache->correctFolderSize('folder');
$cachedDataFolder = $this->cache->get('');
$this->assertNotEqual($cachedDataFolder['size'], -1);