You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/04/10 14:32:30 UTC
(opendal) branch fix-dav-server created (now 780d14abf8)
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a change to branch fix-dav-server
in repository https://gitbox.apache.org/repos/asf/opendal.git
at 780d14abf8 fix(integrations/webdav): Fix read file API changes
This branch includes the following new commits:
new 780d14abf8 fix(integrations/webdav): Fix read file API changes
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opendal) 01/01: fix(integrations/webdav): Fix read file API changes
Posted by xu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch fix-dav-server
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 780d14abf87956f02455ba1cd3f9e5280a8ef490
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Wed Apr 10 22:32:02 2024 +0800
fix(integrations/webdav): Fix read file API changes
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
integrations/dav-server/src/file.rs | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/integrations/dav-server/src/file.rs b/integrations/dav-server/src/file.rs
index 008b35e3f8..4503c400fa 100644
--- a/integrations/dav-server/src/file.rs
+++ b/integrations/dav-server/src/file.rs
@@ -18,7 +18,7 @@
use std::fmt;
use std::io::SeekFrom;
-use bytes::Bytes;
+use bytes::{Bytes, BytesMut};
use dav_server::fs::DavFile;
use dav_server::fs::DavMetaData;
use dav_server::fs::FsFuture;
@@ -34,6 +34,7 @@ pub struct WebdavFile {
op: Operator,
path: String,
state: WebdavFileState,
+ pos: u64,
}
struct WebdavFileState {
@@ -53,6 +54,7 @@ impl WebdavFile {
op,
path,
state: WebdavFileState { reader, writer },
+ pos: 0,
}
}
}
@@ -60,12 +62,14 @@ impl WebdavFile {
impl DavFile for WebdavFile {
fn read_bytes(&mut self, count: usize) -> FsFuture<Bytes> {
async move {
- self.state
+ let mut buf = BytesMut::with_capacity(count);
+ let n = self.state
.reader
- .read(count)
+ .read(&mut buf, self.pos, count)
.await
- .map(Bytes::from)
- .map_err(convert_error)
+ .map_err(convert_error)?;
+ self.pos += n as u64;
+ Ok(buf.split().freeze())
}
.boxed()
}