1
0
Fork 0

allow K/KB as well as KiB for cache size configuration

pull/1455/head
Jordi Boggiano 2013-01-05 20:02:51 +01:00
parent 514a3cde77
commit 2e19d67aec
1 changed files with 7 additions and 4 deletions

View File

@ -139,7 +139,7 @@ class Config
return (int) $this->config[$key];
case 'cache-files-maxsize':
if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) {
if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
throw new \RuntimeException(
"Could not parse the value of 'cache-files-maxsize' from your config: {$this->config[$key]}"
);
@ -147,12 +147,15 @@ class Config
$size = $matches[1];
if (isset($matches[2])) {
switch (strtolower($matches[2])) {
case 'gib':
case 'g':
$size *= 1024;
case 'mib':
// intentional fallthrough
case 'm':
$size *= 1024;
case 'kib':
// intentional fallthrough
case 'k':
$size *= 1024;
break;
}
}