From d99af6c97db311a3e2396bf772eb91a899412899 Mon Sep 17 00:00:00 2001 From: imWildCat Date: Sun, 12 Feb 2023 22:14:37 -0800 Subject: [PATCH] refine lock & clean up --- src/services/webdav/backend.rs | 5 +- src/services/webdav/dir_stream.rs | 5 +- src/services/webdav/list_response.rs | 92 +--------------------------- 3 files changed, 3 insertions(+), 99 deletions(-) diff --git a/src/services/webdav/backend.rs b/src/services/webdav/backend.rs index ab78b7e3a86f..34d0eca3b505 100644 --- a/src/services/webdav/backend.rs +++ b/src/services/webdav/backend.rs @@ -292,10 +292,7 @@ impl Accessor for WebdavBackend { .with_context("service", Scheme::Webdav) })?; - Ok(( - RpList::default(), - DirStream::new(self.root.clone(), result, args.limit()), - )) + Ok((RpList::default(), DirStream::new(result, args.limit()))) } _ => Err(parse_error(resp).await?), // TODO: handle error gracefully } diff --git a/src/services/webdav/dir_stream.rs b/src/services/webdav/dir_stream.rs index 1c878dde0e3e..ccf0bb75618d 100644 --- a/src/services/webdav/dir_stream.rs +++ b/src/services/webdav/dir_stream.rs @@ -19,16 +19,13 @@ use async_trait::async_trait; use super::list_response::Multistatus; pub struct DirStream { - root: String, - size: usize, multistates: Multistatus, } impl DirStream { - pub fn new(root: String, multistates: Multistatus, limit: Option) -> Self { + pub fn new(multistates: Multistatus, limit: Option) -> Self { Self { - root: root.to_owned(), size: limit.unwrap_or(1000), multistates: multistates, } diff --git a/src/services/webdav/list_response.rs b/src/services/webdav/list_response.rs index 5175fe551770..2fe4c284cbd6 100644 --- a/src/services/webdav/list_response.rs +++ b/src/services/webdav/list_response.rs @@ -14,13 +14,6 @@ use serde::Deserialize; -#[derive(Deserialize, Debug, PartialEq)] -#[serde(rename_all = "lowercase")] -pub struct LockEntry { - pub lockscope: LockScopeContainer, - pub locktype: LockTypeContainer, -} - #[derive(Deserialize, Debug, PartialEq)] pub struct LockScopeContainer { #[serde(rename = "$value")] @@ -68,7 +61,6 @@ pub struct Prop { pub getlastmodified: String, pub resourcetype: ResourceTypeContainer, pub lockdiscovery: (), - pub supportedlock: SupportedLock, } #[derive(Deserialize, Debug, PartialEq)] @@ -83,44 +75,10 @@ pub enum ResourceType { Collection, } -#[derive(Deserialize, Debug, PartialEq)] - -pub struct SupportedLock { - lockentry: LockEntry, -} - #[cfg(test)] mod tests { use super::*; use quick_xml::de::from_str; - #[test] - fn test_lockentry() { - let xml = r#" - - - "#; - - let lockentry = from_str::(xml).unwrap(); - assert_eq!(lockentry.lockscope.value, LockScope::Exclusive); - assert_eq!(lockentry.locktype.value, LockType::Write); - } - - #[test] - fn test_supportedlock() { - let xml = r#" - - - - - "#; - - let supportedlock = from_str::(xml).unwrap(); - assert_eq!( - supportedlock.lockentry.lockscope.value, - LockScope::Exclusive - ); - assert_eq!(supportedlock.lockentry.locktype.value, LockType::Write); - } #[test] fn test_propstat() { @@ -150,14 +108,7 @@ mod tests { propstat.prop.resourcetype.value.unwrap(), ResourceType::Collection ); - assert_eq!( - propstat.prop.supportedlock.lockentry.lockscope.value, - LockScope::Exclusive - ); - assert_eq!( - propstat.prop.supportedlock.lockentry.locktype.value, - LockType::Write - ); + assert_eq!(propstat.status, "HTTP/1.1 200 OK"); } @@ -193,26 +144,6 @@ mod tests { response.propstat.prop.resourcetype.value.unwrap(), ResourceType::Collection ); - assert_eq!( - response - .propstat - .prop - .supportedlock - .lockentry - .lockscope - .value, - LockScope::Exclusive - ); - assert_eq!( - response - .propstat - .prop - .supportedlock - .lockentry - .locktype - .value, - LockType::Write - ); assert_eq!(response.propstat.status, "HTTP/1.1 200 OK"); } @@ -250,27 +181,6 @@ mod tests { "Tue, 07 May 2022 05:52:22 GMT" ); assert_eq!(response.propstat.prop.resourcetype.value, None); - - assert_eq!( - response - .propstat - .prop - .supportedlock - .lockentry - .lockscope - .value, - LockScope::Exclusive - ); - assert_eq!( - response - .propstat - .prop - .supportedlock - .lockentry - .locktype - .value, - LockType::Write - ); assert_eq!(response.propstat.status, "HTTP/1.1 200 OK"); }