From 3cb12c6fc1fe5aca0a869c644e21c034d2a4cce9 Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Sun, 12 Jul 2026 21:04:37 +0200 Subject: [PATCH] refactor(readability): and reducing condition evaluation twice on same condition --- src/application/adapters/webdav_adapter.rs | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/application/adapters/webdav_adapter.rs b/src/application/adapters/webdav_adapter.rs index 61d5f8ff..326d653d 100644 --- a/src/application/adapters/webdav_adapter.rs +++ b/src/application/adapters/webdav_adapter.rs @@ -401,19 +401,16 @@ impl WebDavAdapter { /// `quota-used-bytes` known but `quota-available-bytes` unknown (see /// `resolve_quota` in `webdav_handler.rs`). fn folder_prop_is_known(prop: &QualifiedName, quota: Option<(i64, Option)>) -> bool { - prop.namespace == "DAV:" - && (matches!( - prop.name.as_str(), - "resourcetype" - | "displayname" - | "creationdate" - | "getlastmodified" - | "getetag" - | "getcontentlength" - | "getcontenttype" - ) || (quota.is_some() && prop.name == "quota-used-bytes") - || (quota.is_some_and(|(_, available)| available.is_some()) - && prop.name == "quota-available-bytes")) + if prop.namespace != "DAV:" { + return false; + } + match prop.name.as_str() { + "resourcetype" | "displayname" | "creationdate" | "getlastmodified" | "getetag" + | "getcontentlength" | "getcontenttype" => true, + "quota-used-bytes" => quota.is_some(), + "quota-available-bytes" => quota.is_some_and(|(_, available)| available.is_some()), + _ => false, + } } fn file_prop_is_known(prop: &QualifiedName) -> bool { @@ -842,11 +839,11 @@ impl WebDavAdapter { xml_writer.write_event(Event::Empty(BytesStart::new("D:getetag")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:getcontentlength")))?; xml_writer.write_event(Event::Empty(BytesStart::new("D:getcontenttype")))?; - if quota.is_some() { + if let Some((_, available)) = quota { xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-used-bytes")))?; - } - if quota.is_some_and(|(_, available)| available.is_some()) { - xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-available-bytes")))?; + if available.is_some() { + xml_writer.write_event(Event::Empty(BytesStart::new("D:quota-available-bytes")))?; + } } Ok(())