Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class OC_Helper {
* @param int|float $bytes file size in bytes
* @return string a human readable file size
*
* Makes 2048 to 2 kB.
* Makes 2048 to 2 KiB.
*/
public static function humanFileSize(int|float $bytes): string {
if ($bytes < 0) {
Expand All @@ -51,23 +51,23 @@ public static function humanFileSize(int|float $bytes): string {
}
$bytes = round($bytes / 1024, 0);
if ($bytes < 1024) {
return "$bytes KB";
return "$bytes KiB";
}
$bytes = round($bytes / 1024, 1);
if ($bytes < 1024) {
return "$bytes MB";
return "$bytes MiB";
}
$bytes = round($bytes / 1024, 1);
if ($bytes < 1024) {
return "$bytes GB";
return "$bytes GiB";
}
$bytes = round($bytes / 1024, 1);
if ($bytes < 1024) {
return "$bytes TB";
return "$bytes TiB";
}

$bytes = round($bytes / 1024, 1);
return "$bytes PB";
return "$bytes PiB";
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/lib/LegacyHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function testHumanFileSize($expected, $input) {
public function humanFileSizeProvider() {
return [
['0 B', 0],
['1 KB', 1024],
['9.5 MB', 10000000],
['1.3 GB', 1395864371],
['465.7 GB', 500000000000],
['454.7 TB', 500000000000000],
['444.1 PB', 500000000000000000],
['1 KiB', 1024],
['9.5 MiB', 10000000],
['1.3 GiB', 1395864371],
['465.7 GiB', 500000000000],
['454.7 TiB', 500000000000000],
['444.1 PiB', 500000000000000000],
];
}

Expand Down