CS fixes
parent
6ce285b70c
commit
514a3cde77
|
@ -114,7 +114,7 @@ class Cache
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gc($ttl, $cacheMaxSize)
|
public function gc($ttl, $maxSize)
|
||||||
{
|
{
|
||||||
$expire = new \DateTime();
|
$expire = new \DateTime();
|
||||||
$expire->modify('-'.$ttl.' seconds');
|
$expire->modify('-'.$ttl.' seconds');
|
||||||
|
@ -124,12 +124,12 @@ class Cache
|
||||||
unlink($file->getRealPath());
|
unlink($file->getRealPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalCacheSize = $this->filesystem->size($this->root);
|
$totalSize = $this->filesystem->size($this->root);
|
||||||
if ($totalCacheSize > $cacheMaxSize) {
|
if ($totalSize > $maxSize) {
|
||||||
$iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
|
$iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
|
||||||
while ($totalCacheSize > $cacheMaxSize && $iterator->valid()) {
|
while ($totalSize > $maxSize && $iterator->valid()) {
|
||||||
$filepath = $iterator->current()->getRealPath();
|
$filepath = $iterator->current()->getRealPath();
|
||||||
$totalCacheSize -= $this->filesystem->size($filepath);
|
$totalSize -= $this->filesystem->size($filepath);
|
||||||
unlink($filepath);
|
unlink($filepath);
|
||||||
$iterator->next();
|
$iterator->next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ class Config
|
||||||
case 'cache-files-maxsize':
|
case 'cache-files-maxsize':
|
||||||
if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) {
|
if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) {
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
"composer.json contains invalid 'cache-files-maxsize' value: {$this->config[$key]}"
|
"Could not parse the value of 'cache-files-maxsize' from your config: {$this->config[$key]}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$size = $matches[1];
|
$size = $matches[1];
|
||||||
|
@ -155,6 +155,7 @@ class Config
|
||||||
$size *= 1024;
|
$size *= 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $size;
|
return $size;
|
||||||
|
|
||||||
case 'cache-files-ttl':
|
case 'cache-files-ttl':
|
||||||
|
|
|
@ -284,6 +284,7 @@ class Filesystem
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
return $this->directorySize($path);
|
return $this->directorySize($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filesize($path);
|
return filesize($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,6 +299,7 @@ class Filesystem
|
||||||
$size += $file->getSize();
|
$size += $file->getSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,4 +128,3 @@ class FilesystemTest extends TestCase
|
||||||
$this->assertGreaterThanOrEqual(10, $fs->size("$tmp/composer_testdir"));
|
$this->assertGreaterThanOrEqual(10, $fs->size("$tmp/composer_testdir"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue