Skip to content
Snippets Groups Projects
Commit 15b8a3f9 authored by Robin Appelman's avatar Robin Appelman
Browse files

move correctFolderSize from Scanner to Cache

parent 3f644fe7
No related merge requests found
......@@ -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
*
......
......@@ -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);
}
}
}
......@@ -50,7 +50,7 @@ class Watcher {
} else {
$this->scanner->scanFile($path);
}
$this->scanner->correctFolderSize($path);
$this->cache->correctFolderSize($path);
}
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment