Skip to content

Commit c609da6

Browse files
Morgy93Copilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 64d2ab0 commit c609da6

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/Console/Command/System/CheckCommand.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,24 @@ private function getDiskSpace(): string
673673
$totalSpace = disk_total_space('.');
674674
$freeSpace = disk_free_space('.');
675675

676+
if ($totalSpace === false || $freeSpace === false) {
677+
return 'Unknown';
678+
}
679+
680+
if ($totalSpace <= 0) {
681+
$totalGB = 0.0;
682+
$usedGB = 0.0;
683+
$usedPercent = 0.0;
684+
685+
return "$usedGB GB / $totalGB GB ($usedPercent%)";
686+
}
687+
676688
$totalGB = round($totalSpace / 1024 / 1024 / 1024, 2);
677689
$freeGB = round($freeSpace / 1024 / 1024 / 1024, 2);
678690
$usedGB = round($totalGB - $freeGB, 2);
679-
$usedPercent = round(($usedGB / $totalGB) * 100, 2);
691+
$usedPercent = $totalGB > 0.0
692+
? round(($usedGB / $totalGB) * 100, 2)
693+
: 0.0;
680694

681695
return "$usedGB GB / $totalGB GB ($usedPercent%)";
682696
}

0 commit comments

Comments
 (0)