handle special case size=1 in format_filesize()

This commit is contained in:
Uwe Steinmann 2021-10-04 20:24:51 +02:00
parent 7bac4e730e
commit 790eef7e84

View File

@ -84,8 +84,9 @@ class SeedDMS_Core_File {
*/
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
if ($size == 0) return('0 Bytes');
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
if ($size == 1) return('1 Byte');
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
} /* }}} */
/**