Skip to content

Commit

Permalink
Add Windows support for storage monitor (paritytech#13466)
Browse files Browse the repository at this point in the history
* Add Windows support for storage monitor

* Apply suggested changes
  • Loading branch information
ark0f authored and ukint-vs committed Apr 10, 2023
1 parent 9ed832b commit dd8ba95
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
57 changes: 47 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions client/storage-monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use clap::Args;
use fs4::statvfs;
use sc_client_db::DatabaseSource;
use sp_core::traits::SpawnEssentialNamed;
use std::{
Expand Down Expand Up @@ -118,8 +117,7 @@ impl StorageMonitorService {

/// Returns free space in MB, or error if statvfs failed.
fn free_space(path: &Path) -> Result<u64, Error> {
let amount = statvfs(path)?;
Ok(amount.available_space() / (1024 * 1024))
Ok(fs4::available_space(path).map(|s| s / 1_000_000)?)
}

/// Checks if the amount of free space for given `path` is above given `threshold`.
Expand Down

0 comments on commit dd8ba95

Please sign in to comment.