From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A16841FF173 for ; Mon, 13 Jan 2025 14:26:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F28EC2F4FD; Mon, 13 Jan 2025 14:25:58 +0100 (CET) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Mon, 13 Jan 2025 14:25:50 +0100 Message-Id: <20250113132553.435319-2-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250113132553.435319-1-m.sandoval@proxmox.com> References: <20250113132553.435319-1-m.sandoval@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.346 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_ASCII_DIVIDERS 0.8 Email that uses ascii formatting dividers and possible spam tricks KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_SBL_A 0.1 Contains URL's A record listed in the Spamhaus SBL blocklist [185.199.109.153, 185.199.111.153, 185.199.108.153, 185.199.110.153] Subject: [pbs-devel] [PATCH backup 2/5] metric_collection: remove redundant map_or X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Fixes: warning: this `map_or` is redundant --> src/server/metric_collection/mod.rs:172:20 | 172 | if config | ____________________^ 173 | | .get_maintenance_mode() 174 | | .map_or(false, |mode| mode.check(Some(Operation::Read)).is_err()) | |_____________________________________________________________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or = note: `#[warn(clippy::unnecessary_map_or)]` on by default help: use is_some_and instead | 172 ~ if config 173 + .get_maintenance_mode().is_some_and(|mode| mode.check(Some(Operation::Read)).is_err()) | Signed-off-by: Maximiliano Sandoval --- pbs-datastore/src/datastore.rs | 6 +++--- src/api2/admin/datastore.rs | 2 +- src/api2/config/datastore.rs | 2 +- src/api2/config/remote.rs | 2 +- src/bin/proxmox_backup_debug/inspect.rs | 2 +- src/bin/proxmox_backup_manager/datastore.rs | 2 +- src/server/metric_collection/mod.rs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 0801b4bf..fd3990d6 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -179,9 +179,9 @@ impl Drop for DataStore { let remove_from_cache = last_task && pbs_config::datastore::config() .and_then(|(s, _)| s.lookup::("datastore", self.name())) - .map_or(false, |c| { + .is_ok_and(|c| { c.get_maintenance_mode() - .map_or(false, |m| m.clear_from_cache()) + .is_some_and(|m| m.clear_from_cache()) }); if remove_from_cache { @@ -287,7 +287,7 @@ impl DataStore { let datastore: DataStoreConfig = config.lookup("datastore", name)?; if datastore .get_maintenance_mode() - .map_or(false, |m| m.clear_from_cache()) + .is_some_and(|m| m.clear_from_cache()) { // the datastore drop handler does the checking if tasks are running and clears the // cache entry, so we just have to trigger it here diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index c611f593..f5d80d61 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -2601,7 +2601,7 @@ fn do_unmount_device( active_operations = task_tracking::get_active_operations(&datastore.name)?; } - if aborted || worker.map_or(false, |w| w.abort_requested()) { + if aborted || worker.is_some_and(|w| w.abort_requested()) { let _ = expect_maintanance_unmounting(&datastore.name) .inspect_err(|e| warn!("maintenance mode was not as expected: {e}")) .and_then(|(lock, config)| { diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index df268161..fe3260f6 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -105,7 +105,7 @@ pub(crate) fn do_create_datastore( for file in dir { let name = file?.file_name(); let name = name.to_str(); - if !name.map_or(false, |name| name.starts_with('.') || name == "lost+found") { + if !name.is_some_and(|name| name.starts_with('.') || name == "lost+found") { is_empty = false; break; } diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs index 069aef28..7d5173ef 100644 --- a/src/api2/config/remote.rs +++ b/src/api2/config/remote.rs @@ -268,7 +268,7 @@ pub fn delete_remote(name: String, digest: Option) -> Result<(), Error> let job_list: Vec = sync_jobs.convert_to_typed_array("sync")?; for job in job_list { - if job.remote.map_or(false, |id| id == name) { + if job.remote.is_some_and(|id| id == name) { param_bail!( "name", "remote '{}' is used by sync job '{}' (datastore '{}')", diff --git a/src/bin/proxmox_backup_debug/inspect.rs b/src/bin/proxmox_backup_debug/inspect.rs index 9a75bae1..75a36870 100644 --- a/src/bin/proxmox_backup_debug/inspect.rs +++ b/src/bin/proxmox_backup_debug/inspect.rs @@ -429,7 +429,7 @@ fn inspect_device(device: String, param: Value) -> Result<(), Error> { && entry .file_name() .to_str() - .map_or(false, |name| name == ".chunks") + .is_some_and(|name| name == ".chunks") { let store_path = entry .path() diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs index 0918af3a..1922a55a 100644 --- a/src/bin/proxmox_backup_manager/datastore.rs +++ b/src/bin/proxmox_backup_manager/datastore.rs @@ -273,7 +273,7 @@ async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result (DiskStat, Vec) { for config in datastore_list { if config .get_maintenance_mode() - .map_or(false, |mode| mode.check(Some(Operation::Read)).is_err()) + .is_some_and(|mode| mode.check(Some(Operation::Read)).is_err()) { continue; } -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel