From 87b386761db7c95fc0ceb33595d98aeaac9b525b Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 15 Sep 2023 11:13:40 +0800 Subject: [PATCH] refactor(services/webdav): Use OpRead in `webdav_get`. (#3081) --- core/src/services/webdav/backend.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/src/services/webdav/backend.rs b/core/src/services/webdav/backend.rs index 8d8771472df..549a6b34ff3 100644 --- a/core/src/services/webdav/backend.rs +++ b/core/src/services/webdav/backend.rs @@ -263,7 +263,7 @@ impl Accessor for WebdavBackend { } async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> { - let resp = self.webdav_get(path, args.range()).await?; + let resp = self.webdav_get(path, args).await?; let status = resp.status(); match status { StatusCode::OK | StatusCode::PARTIAL_CONTENT => { @@ -408,11 +408,7 @@ impl Accessor for WebdavBackend { } impl WebdavBackend { - async fn webdav_get( - &self, - path: &str, - range: BytesRange, - ) -> Result> { + async fn webdav_get(&self, path: &str, args: OpRead) -> Result> { let p = build_rooted_abs_path(&self.root, path); let url: String = format!("{}{}", self.endpoint, percent_encode_path(&p)); @@ -422,6 +418,7 @@ impl WebdavBackend { req = req.header(header::AUTHORIZATION, auth.clone()) } + let range = args.range(); if !range.is_full() { req = req.header(header::RANGE, range.to_header()); }