Skip to content

Commit

Permalink
Fix printing farm info on Windows by avoiding accessing locked file
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Dec 20, 2023
1 parent 4972daf commit 3629234
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod dsn;

use crate::commands::farm::dsn::configure_dsn;
use crate::commands::shared::print_disk_farm_info;
use crate::utils::shutdown_signal;
use anyhow::anyhow;
use bytesize::ByteSize;
Expand Down Expand Up @@ -493,7 +492,17 @@ where
};

if !no_info {
print_disk_farm_info(disk_farm.directory, disk_farm_index);
let info = single_disk_farm.info();
println!("Single disk farm {disk_farm_index}:");
println!(" ID: {}", info.id());
println!(" Genesis hash: 0x{}", hex::encode(info.genesis_hash()));
println!(" Public key: 0x{}", hex::encode(info.public_key()));
println!(
" Allocated space: {} ({})",
bytesize::to_string(info.allocated_space(), true),
bytesize::to_string(info.allocated_space(), false)
);
println!(" Directory: {}", disk_farm.directory.display());
}

single_disk_farms.push(single_disk_farm);
Expand Down
6 changes: 6 additions & 0 deletions crates/subspace-farmer/src/single_disk_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ impl SingleDiskFarmInfo {
}

/// Summary of single disk farm for presentational purposes
#[derive(Debug)]
pub enum SingleDiskFarmSummary {
/// Farm was found and read successfully
Found {
Expand Down Expand Up @@ -1312,6 +1313,11 @@ impl SingleDiskFarm {
self.single_disk_farm_info.id()
}

/// Info of this farm
pub fn info(&self) -> &SingleDiskFarmInfo {
&self.single_disk_farm_info
}

/// Number of sectors in this farm
pub fn total_sectors_count(&self) -> SectorIndex {
self.total_sectors_count
Expand Down

0 comments on commit 3629234

Please sign in to comment.