5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-03-03 12:58:28 +03:00

metric_collection: remove redundant map_or

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 <m.sandoval@proxmox.com>
This commit is contained in:
Maximiliano Sandoval 2025-01-13 14:25:50 +01:00 committed by Dietmar Maurer
parent 0185228ad7
commit 414f3656a8
7 changed files with 9 additions and 9 deletions

View File

@ -179,9 +179,9 @@ impl Drop for DataStore {
let remove_from_cache = last_task
&& pbs_config::datastore::config()
.and_then(|(s, _)| s.lookup::<DataStoreConfig>("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

View File

@ -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)| {

View File

@ -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;
}

View File

@ -268,7 +268,7 @@ pub fn delete_remote(name: String, digest: Option<String>) -> Result<(), Error>
let job_list: Vec<SyncJobConfig> = 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 '{}')",

View File

@ -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()

View File

@ -273,7 +273,7 @@ async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result<Va
store
.backing_device
.clone()
.map_or(false, |device| device.eq(&uuid))
.is_some_and(|device| device.eq(&uuid))
})
.collect();

View File

@ -171,7 +171,7 @@ fn collect_disk_stats_sync() -> (DiskStat, Vec<DiskStat>) {
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;
}