move correctFolderSize from Scanner to Cache
This commit is contained in:
parent
3f644fe70c
commit
15b8a3f987
4 changed files with 18 additions and 18 deletions
16
lib/files/cache/cache.php
vendored
16
lib/files/cache/cache.php
vendored
|
@ -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
|
||||
*
|
||||
|
|
16
lib/files/cache/scanner.php
vendored
16
lib/files/cache/scanner.php
vendored
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
lib/files/cache/watcher.php
vendored
2
lib/files/cache/watcher.php
vendored
|
@ -50,7 +50,7 @@ class Watcher {
|
|||
} else {
|
||||
$this->scanner->scanFile($path);
|
||||
}
|
||||
$this->scanner->correctFolderSize($path);
|
||||
$this->cache->correctFolderSize($path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
tests/lib/files/cache/scanner.php
vendored
2
tests/lib/files/cache/scanner.php
vendored
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue