mirror of
https://github.com/qwjyh/xdbm
synced 2024-11-22 06:40:12 +09:00
update dependency: sysinfo 0.29 -> 0.30
This commit is contained in:
parent
0f7095b229
commit
78b3d0d308
4 changed files with 30 additions and 25 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -1048,9 +1048,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sysinfo"
|
name = "sysinfo"
|
||||||
version = "0.29.11"
|
version = "0.30.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cd727fc423c2060f6c92d9534cef765c65a6ed3f428a03d7def74a8c4348e666"
|
checksum = "732ffa00f53e6b2af46208fba5718d9662a421049204e156328b66791ffa15ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
|
@ -1059,7 +1059,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
"winapi",
|
"windows",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1302,6 +1302,16 @@ version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows"
|
||||||
|
version = "0.52.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core",
|
||||||
|
"windows-targets 0.52.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
|
|
|
@ -14,7 +14,7 @@ keywords = ["cli", "backup"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.4.0", features = ["cargo", "derive"] }
|
clap = { version = "4.4.0", features = ["cargo", "derive"] }
|
||||||
sysinfo = { version = "0.29.8", features = ["serde"] }
|
sysinfo = { version = "0.30", features = ["serde"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
clap-verbosity-flag = "2.0.1"
|
clap-verbosity-flag = "2.0.1"
|
||||||
clap_complete = "4.5.1"
|
clap_complete = "4.5.1"
|
||||||
|
|
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::fs::{File, OpenOptions};
|
use std::fs::{File, OpenOptions};
|
||||||
use std::io::{BufRead, BufReader, BufWriter};
|
use std::io::{BufRead, BufReader, BufWriter};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::System;
|
||||||
|
|
||||||
/// YAML file to store known devices.
|
/// YAML file to store known devices.
|
||||||
pub const DEVICESFILE: &str = "devices.yml";
|
pub const DEVICESFILE: &str = "devices.yml";
|
||||||
|
@ -25,18 +25,17 @@ impl Device {
|
||||||
/// Create new `Device` of name `name`. Additional data is obtained via sysinfo.
|
/// Create new `Device` of name `name`. Additional data is obtained via sysinfo.
|
||||||
/// Filling fields which one failed to get is filled with "unknown".
|
/// Filling fields which one failed to get is filled with "unknown".
|
||||||
pub fn new(name: String) -> Device {
|
pub fn new(name: String) -> Device {
|
||||||
let sys = System::new();
|
|
||||||
Device {
|
Device {
|
||||||
name,
|
name,
|
||||||
os_name: sys.name().unwrap_or_else(|| {
|
os_name: System::name().unwrap_or_else(|| {
|
||||||
warn!("Failed to get OS name. Saving as \"unknown\".");
|
warn!("Failed to get OS name. Saving as \"unknown\".");
|
||||||
"unknown".to_string()
|
"unknown".to_string()
|
||||||
}),
|
}),
|
||||||
os_version: sys.os_version().unwrap_or_else(|| {
|
os_version: System::os_version().unwrap_or_else(|| {
|
||||||
warn!("Failed to get OS version. Saving as \"unknown\".");
|
warn!("Failed to get OS version. Saving as \"unknown\".");
|
||||||
"unknown".to_string()
|
"unknown".to_string()
|
||||||
}),
|
}),
|
||||||
hostname: sys.host_name().unwrap_or_else(|| {
|
hostname: System::host_name().unwrap_or_else(|| {
|
||||||
warn!("Failed to get hostname. Saving as \"unknown\".");
|
warn!("Failed to get hostname. Saving as \"unknown\".");
|
||||||
"unknown".to_string()
|
"unknown".to_string()
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use byte_unit::Byte;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::{self, Path};
|
use std::path::{self, Path};
|
||||||
use std::{collections::BTreeMap, fmt};
|
use std::{collections::BTreeMap, fmt};
|
||||||
use sysinfo::{Disk, DiskExt, SystemExt};
|
use sysinfo::{Disk, Disks};
|
||||||
|
|
||||||
use super::local_info::{self, LocalInfo};
|
use super::local_info::{self, LocalInfo};
|
||||||
|
|
||||||
|
@ -57,7 +57,10 @@ impl PhysicalDrivePartition {
|
||||||
.to_string();
|
.to_string();
|
||||||
let fs = disk.file_system();
|
let fs = disk.file_system();
|
||||||
trace!("fs: {:?}", fs);
|
trace!("fs: {:?}", fs);
|
||||||
let fs = std::str::from_utf8(fs)?;
|
let fs: String = fs
|
||||||
|
.to_str()
|
||||||
|
.context("Failed to convert file_system osstr")?
|
||||||
|
.to_owned();
|
||||||
let local_info = LocalInfo::new(alias, disk.mount_point().to_path_buf());
|
let local_info = LocalInfo::new(alias, disk.mount_point().to_path_buf());
|
||||||
Ok(PhysicalDrivePartition {
|
Ok(PhysicalDrivePartition {
|
||||||
name,
|
name,
|
||||||
|
@ -161,13 +164,9 @@ pub fn select_physical_storage(
|
||||||
) -> Result<PhysicalDrivePartition> {
|
) -> Result<PhysicalDrivePartition> {
|
||||||
trace!("select_physical_storage");
|
trace!("select_physical_storage");
|
||||||
// get disk info from sysinfo
|
// get disk info from sysinfo
|
||||||
let sys_disks =
|
let sys_disks = Disks::new_with_refreshed_list();
|
||||||
sysinfo::System::new_with_specifics(sysinfo::RefreshKind::new().with_disks_list());
|
|
||||||
trace!("refresh");
|
|
||||||
// sys_disks.refresh_disks_list();
|
|
||||||
// sys_disks.refresh_disks();
|
|
||||||
trace!("Available disks");
|
trace!("Available disks");
|
||||||
for disk in sys_disks.disks() {
|
for disk in &sys_disks {
|
||||||
trace!("{:?}", disk)
|
trace!("{:?}", disk)
|
||||||
}
|
}
|
||||||
let disk = select_sysinfo_disk(&sys_disks)?;
|
let disk = select_sysinfo_disk(&sys_disks)?;
|
||||||
|
@ -175,14 +174,13 @@ pub fn select_physical_storage(
|
||||||
Ok(storage)
|
Ok(storage)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_sysinfo_disk(sysinfo: &sysinfo::System) -> Result<&Disk> {
|
fn select_sysinfo_disk(disks: &sysinfo::Disks) -> Result<&Disk> {
|
||||||
let available_disks = sysinfo
|
let available_disks = disks
|
||||||
.disks()
|
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, disk)| {
|
.map(|(i, disk)| {
|
||||||
let name = disk.name().to_str().unwrap_or("");
|
let name = disk.name().to_str().unwrap_or("");
|
||||||
let fs: &str = std::str::from_utf8(disk.file_system()).unwrap_or("unknown");
|
let fs: &str = disk.file_system().to_str().unwrap_or("unknown");
|
||||||
let kind = format!("{:?}", disk.kind());
|
let kind = format!("{:?}", disk.kind());
|
||||||
let mount_path = disk.mount_point();
|
let mount_path = disk.mount_point();
|
||||||
let total_space = byte_unit::Byte::from_bytes(disk.total_space().into())
|
let total_space = byte_unit::Byte::from_bytes(disk.total_space().into())
|
||||||
|
@ -203,10 +201,8 @@ fn select_sysinfo_disk(sysinfo: &sysinfo::System) -> Result<&Disk> {
|
||||||
let disk = inquire::Select::new("Select drive:", available_disks).prompt()?;
|
let disk = inquire::Select::new("Select drive:", available_disks).prompt()?;
|
||||||
let disk_num: usize = disk.split(':').next().unwrap().parse().unwrap();
|
let disk_num: usize = disk.split(':').next().unwrap().parse().unwrap();
|
||||||
trace!("disk_num: {}", disk_num);
|
trace!("disk_num: {}", disk_num);
|
||||||
let disk = sysinfo
|
let disk = disks
|
||||||
.disks()
|
.get(disk_num)
|
||||||
.iter()
|
|
||||||
.nth(disk_num)
|
|
||||||
.context("no disk matched with selected one.")?;
|
.context("no disk matched with selected one.")?;
|
||||||
trace!("selected disk: {:?}", disk);
|
trace!("selected disk: {:?}", disk);
|
||||||
Ok(disk)
|
Ok(disk)
|
||||||
|
|
Loading…
Reference in a new issue