Skip to content

Commit

Permalink
Bugfix: StoragePool::get_free_space() would sometimes return the wron…
Browse files Browse the repository at this point in the history
…g value (the free space on the last storage pool drive, instead of the specified drive)

Fixes #217
  • Loading branch information
gboudreau committed Feb 26, 2020
1 parent ebd72e3 commit 6bf49d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion includes/CLI/StatsCliRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ public function run() {
if (empty($stat->total_space)) {
$this->log(" Offline ");
} else {
$this->log(sprintf('%5.0f', $stat->total_space/1024/1024) . "G - " . sprintf('%5.0f', $stat->used_space/1024/1024) . "G = " . sprintf('%5.0f', $stat->free_space/1024/1024) . "G + " . sprintf('%5.0f', $stat->trash_size/1024/1024) . "G = " . sprintf('%5.0f', $stat->potential_available_space/1024/1024) . "G");
$this->log(
sprintf('%5.0f', $stat->total_space/1024/1024) . "G" // Total
. ' - ' . sprintf('%5.0f', $stat->used_space/1024/1024). "G" // - Used
. ' = ' . sprintf('%5.0f', $stat->free_space/1024/1024) . "G" // = Free
. ' + ' . sprintf('%5.0f', $stat->trash_size/1024/1024) . "G" // + Trash
. ' = ' . sprintf('%5.0f', $stat->potential_available_space/1024/1024) . "G" // = Possible
);
}
}
$this->log();
Expand Down
6 changes: 3 additions & 3 deletions includes/StoragePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public static function get_file_copies_inodes($share, $file_path, $filename, &$f
return $file_copies_inodes;
}

public static function get_free_space($sp_drive) {
public static function get_free_space($for_sp_drive) {
if (time() > static::$last_df_time + Config::get(CONFIG_DF_CACHE_TIME)) {
$dfs = [];
exec(ConfigHelper::$df_command, $responses);
Expand Down Expand Up @@ -353,10 +353,10 @@ public static function get_free_space($sp_drive) {
static::$last_dfs = $dfs;
}

if (empty(static::$last_dfs[$sp_drive])) {
if (empty(static::$last_dfs[$for_sp_drive])) {
return FALSE;
}
return static::$last_dfs[$sp_drive];
return static::$last_dfs[$for_sp_drive];
}

public static function choose_target_drives($filesize_kb, $include_full_drives, $share, $path, $log_prefix = '', &$is_sticky = NULL) {
Expand Down

0 comments on commit 6bf49d4

Please sign in to comment.