Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit 3eaff76

Browse files
authored
Merge pull request #37 from jahvi/master
Include 2 decimals in downloads filesize list
2 parents 30c8467 + 789048f commit 3eaff76

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Meanbee/Magedbm/Command/ListCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
6565
foreach ($results as $item) {
6666
$itemKeyChunks = explode('/', $item['Key']);
6767

68+
// If name presented, show downloads for that name
6869
if ($name) {
69-
// If name presented, show downloads for that name
70-
$this->getOutput()->writeln(sprintf('%s %dMB', array_pop($itemKeyChunks), $item['Size'] / 1024 / 1024));
70+
// Get file size in MB
71+
$fileSize = $item['Size'] / 1024 / 1024;
72+
73+
// If file size is less than 1MB display 1 decimal place
74+
$fileSize = ($fileSize < 1) ? round($fileSize, 1) : round($fileSize);
75+
76+
$this->getOutput()->writeln(sprintf('%s %sMB', array_pop($itemKeyChunks), $fileSize));
7177
} else {
7278
// Otherwise show uniqued list of available names
7379
if (!in_array($itemKeyChunks[0], $names)) {

0 commit comments

Comments
 (0)