chore: optimize code
This commit is contained in:
parent
8d03ec151a
commit
e01f2030e1
1 changed files with 7 additions and 9 deletions
|
@ -816,10 +816,12 @@ struct PathItem {
|
||||||
impl PathItem {
|
impl PathItem {
|
||||||
pub fn to_dav_xml(&self, prefix: &str) -> String {
|
pub fn to_dav_xml(&self, prefix: &str) -> String {
|
||||||
let mtime = Utc.timestamp_millis(self.mtime as i64).to_rfc2822();
|
let mtime = Utc.timestamp_millis(self.mtime as i64).to_rfc2822();
|
||||||
|
let href = encode_uri(&format!("{}{}", prefix, &self.name));
|
||||||
|
let displayname = escape_str_pcdata(&self.base_name);
|
||||||
match self.path_type {
|
match self.path_type {
|
||||||
PathType::Dir | PathType::SymlinkDir => format!(
|
PathType::Dir | PathType::SymlinkDir => format!(
|
||||||
r#"<D:response>
|
r#"<D:response>
|
||||||
<D:href>{}{}</D:href>
|
<D:href>{}</D:href>
|
||||||
<D:propstat>
|
<D:propstat>
|
||||||
<D:prop>
|
<D:prop>
|
||||||
<D:displayname>{}</D:displayname>
|
<D:displayname>{}</D:displayname>
|
||||||
|
@ -829,14 +831,11 @@ impl PathItem {
|
||||||
<D:status>HTTP/1.1 200 OK</D:status>
|
<D:status>HTTP/1.1 200 OK</D:status>
|
||||||
</D:propstat>
|
</D:propstat>
|
||||||
</D:response>"#,
|
</D:response>"#,
|
||||||
prefix,
|
href, displayname, mtime
|
||||||
encode_uri(&self.name),
|
|
||||||
escape_str_pcdata(&self.base_name),
|
|
||||||
mtime
|
|
||||||
),
|
),
|
||||||
PathType::File | PathType::SymlinkFile => format!(
|
PathType::File | PathType::SymlinkFile => format!(
|
||||||
r#"<D:response>
|
r#"<D:response>
|
||||||
<D:href>{}{}</D:href>
|
<D:href>{}</D:href>
|
||||||
<D:propstat>
|
<D:propstat>
|
||||||
<D:prop>
|
<D:prop>
|
||||||
<D:displayname>{}</D:displayname>
|
<D:displayname>{}</D:displayname>
|
||||||
|
@ -847,9 +846,8 @@ impl PathItem {
|
||||||
<D:status>HTTP/1.1 200 OK</D:status>
|
<D:status>HTTP/1.1 200 OK</D:status>
|
||||||
</D:propstat>
|
</D:propstat>
|
||||||
</D:response>"#,
|
</D:response>"#,
|
||||||
prefix,
|
href,
|
||||||
encode_uri(&self.name),
|
displayname,
|
||||||
escape_str_pcdata(&self.base_name),
|
|
||||||
self.size.unwrap_or_default(),
|
self.size.unwrap_or_default(),
|
||||||
mtime
|
mtime
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue