summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClement Tsang <34804052+ClementTsang@users.noreply.github.com>2023-12-25 17:26:32 -0500
committerGitHub <noreply@github.com>2023-12-25 17:26:32 -0500
commitc10779ecc0cda4a4d44cc2cb5fd9232fb32c9d05 (patch)
tree9494285ff1cf7abeca261784e5edc442bf654a69 /src
parenta1168cac67088504c01ecdcde8c5d0cc50252126 (diff)
refactor: fix macro formatting in disk data collection code (#1363)
Diffstat (limited to 'src')
-rw-r--r--src/app/data_farmer.rs55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/app/data_farmer.rs b/src/app/data_farmer.rs
index 73881a4b..669e4630 100644
--- a/src/app/data_farmer.rs
+++ b/src/app/data_farmer.rs
@@ -341,20 +341,25 @@ impl DataCollection {
for (itx, device) in disks.iter().enumerate() {
let checked_name = {
- cfg_if::cfg_if! {
- if #[cfg(target_os = "windows")] {
- match &device.volume_name {
- Some(volume_name) => Some(volume_name.as_str()),
- None => device.name.split('/').last(),
- }
- } else {
- #[cfg(feature = "zfs")]
- if ! device.name.starts_with('/'){
+ #[cfg(target_os = "windows")]
+ {
+ match &device.volume_name {
+ Some(volume_name) => Some(volume_name.as_str()),
+ None => device.name.split('/').last(),
+ }
+ }
+ #[cfg(not(target_os = "windows"))]
+ {
+ #[cfg(feature = "zfs")]
+ {
+ if !device.name.starts_with('/') {
Some(device.name.as_str()) // use the whole zfs dataset name
} else {
device.name.split('/').last()
}
- #[cfg(not(feature = "zfs"))]
+ }
+ #[cfg(not(feature = "zfs"))]
+ {
device.name.split('/').last()
}
}
@@ -362,22 +367,26 @@ impl DataCollection {
if let Some(checked_name) = checked_name {
let io_device = {
- cfg_if::cfg_if! {
- if #[cfg(target_os = "macos")] {
- use std::sync::OnceLock;
- use regex::Regex;
-
- // Must trim one level further for macOS!
- static DISK_REGEX: OnceLock<Regex> = OnceLock::new();
- if let Some(new_name) = DISK_REGEX.get_or_init(|| Regex::new(r"disk\d+").unwrap()).find(checked_name) {
- io.get(new_name.as_str())
- } else {
- None
- }
+ #[cfg(target_os = "macos")]
+ {
+ use regex::Regex;
+ use std::sync::OnceLock;
+
+ // Must trim one level further for macOS!
+ static DISK_REGEX: OnceLock<Regex> = OnceLock::new();
+ if let Some(new_name) = DISK_REGEX
+ .get_or_init(|| Regex::new(r"disk\d+").unwrap())
+ .find(checked_name)
+ {
+ io.get(new_name.as_str())
} else {
- io.get(checked_name)
+ None
}
}
+ #[cfg(not(target_os = "macos"))]
+ {
+ io.get(checked_name)
+ }
};
if let Some(io_device) = io_device {