prevent divide by zero, make error messages more descriptive
This commit is contained in:
parent
27ca8d8674
commit
8759e2bdb4
|
@ -1435,14 +1435,17 @@ function getLoad() {
|
|||
function getDiskPercent($path = ZM_DIR_EVENTS) {
|
||||
$total = disk_total_space($path);
|
||||
if ( $total === false ) {
|
||||
Error("disk_total_space returned false for " . $path );
|
||||
Error("disk_total_space returned false. Verify the web account user has access to " . $path );
|
||||
return 0;
|
||||
} elseif ( $total == 0 ) {
|
||||
Error("disk_total_space indicates the following path has a filesystem size of zero bytes" . $path );
|
||||
return 100;
|
||||
}
|
||||
$free = disk_free_space($path);
|
||||
if ( $free === false ) {
|
||||
Error("disk_free_space returned false for " . $path );
|
||||
Error("disk_free_space returned false. Verify the web account user has access to " . $path );
|
||||
}
|
||||
$space = round(($total - $free) / $total * 100);
|
||||
$space = round((($total - $free) / $total) * 100);
|
||||
return( $space );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue