clippy: convert single match to if let
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
ea368a06cd
commit
b92cad0938
@ -35,13 +35,10 @@ use crate::api2::types::{Authid, APTUpdateInfo, NODE_SCHEMA, UPID_SCHEMA};
|
||||
/// List available APT updates
|
||||
fn apt_update_available(_param: Value) -> Result<Value, Error> {
|
||||
|
||||
match apt::pkg_cache_expired() {
|
||||
Ok(false) => {
|
||||
if let Ok(false) = apt::pkg_cache_expired() {
|
||||
if let Ok(Some(cache)) = apt::read_pkg_state() {
|
||||
return Ok(json!(cache.package_status));
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
||||
let cache = apt::update_cache()?;
|
||||
|
@ -127,8 +127,7 @@ fn datastore_status(
|
||||
rrd_mode,
|
||||
);
|
||||
|
||||
match (total_res, used_res) {
|
||||
(Some((start, reso, total_list)), Some((_, _, used_list))) => {
|
||||
if let (Some((start, reso, total_list)), Some((_, _, used_list))) = (total_res, used_res) {
|
||||
let mut usage_list: Vec<f64> = Vec::new();
|
||||
let mut time_list: Vec<u64> = Vec::new();
|
||||
let mut history = Vec::new();
|
||||
@ -168,8 +167,6 @@ fn datastore_status(
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
list.push(entry);
|
||||
|
@ -39,13 +39,12 @@ pub fn do_garbage_collection_job(
|
||||
|
||||
let status = worker.create_state(&result);
|
||||
|
||||
match job.finish(status) {
|
||||
Err(err) => eprintln!(
|
||||
if let Err(err) = job.finish(status) {
|
||||
eprintln!(
|
||||
"could not finish job state for {}: {}",
|
||||
job.jobtype().to_string(),
|
||||
err
|
||||
),
|
||||
Ok(_) => (),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(email) = email {
|
||||
|
@ -207,12 +207,9 @@ impl Job {
|
||||
/// Start the job and update the statefile accordingly
|
||||
/// Fails if the job was already started
|
||||
pub fn start(&mut self, upid: &str) -> Result<(), Error> {
|
||||
match self.state {
|
||||
JobState::Started { .. } => {
|
||||
if let JobState::Started { .. } = self.state {
|
||||
bail!("cannot start job that is started!");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
self.state = JobState::Started {
|
||||
upid: upid.to_string(),
|
||||
|
@ -83,13 +83,12 @@ pub fn do_verification_job(
|
||||
|
||||
let status = worker.create_state(&job_result);
|
||||
|
||||
match job.finish(status) {
|
||||
Err(err) => eprintln!(
|
||||
if let Err(err) = job.finish(status) {
|
||||
eprintln!(
|
||||
"could not finish job state for {}: {}",
|
||||
job.jobtype().to_string(),
|
||||
err
|
||||
),
|
||||
Ok(_) => (),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(email) = email {
|
||||
|
@ -566,8 +566,7 @@ pub fn get_partition_type_info() -> Result<HashMap<String, Vec<String>>, Error>
|
||||
let mut res: HashMap<String, Vec<String>> = HashMap::new();
|
||||
|
||||
let output: serde_json::Value = output.parse()?;
|
||||
match output["blockdevices"].as_array() {
|
||||
Some(list) => {
|
||||
if let Some(list) = output["blockdevices"].as_array() {
|
||||
for info in list {
|
||||
let path = match info["path"].as_str() {
|
||||
Some(p) => p,
|
||||
@ -581,10 +580,6 @@ pub fn get_partition_type_info() -> Result<HashMap<String, Vec<String>>, Error>
|
||||
devices.push(path.to_string());
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
||||
}
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
|
@ -357,18 +357,12 @@ pub fn find_all_mappings() -> Result<impl Iterator<Item = (String, Option<String
|
||||
// get map of all /dev/loop mappings belonging to us
|
||||
let mut loopmap = HashMap::new();
|
||||
for ent in fs::scan_subdir(libc::AT_FDCWD, Path::new("/dev/"), &LOOPDEV_REGEX)? {
|
||||
match ent {
|
||||
Ok(ent) => {
|
||||
if let Ok(ent) = ent {
|
||||
let loopdev = format!("/dev/{}", ent.file_name().to_string_lossy());
|
||||
match get_backing_file(&loopdev) {
|
||||
Ok(file) => {
|
||||
if let Ok(file) = get_backing_file(&loopdev) {
|
||||
// insert filename only, strip RUN_DIR/
|
||||
loopmap.insert(file[RUN_DIR.len()+1..].to_owned(), loopdev);
|
||||
},
|
||||
Err(_) => {},
|
||||
}
|
||||
},
|
||||
Err(_) => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user