mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-25 13:36:50 +00:00
Optimization FileReader
This commit is contained in:
+27
-24
@@ -961,31 +961,34 @@ impl RemoteFileReader {
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl Reader for RemoteFileReader {
|
impl Reader for RemoteFileReader {
|
||||||
async fn read_at(&mut self, offset: usize, buf: &mut [u8]) -> Result<usize> {
|
async fn read_at(&mut self, offset: usize, buf: &mut [u8]) -> Result<usize> {
|
||||||
unimplemented!()
|
let request = ReadAtRequest {
|
||||||
// let request = ReadAtRequest {
|
disk: self.root.to_string_lossy().to_string(),
|
||||||
// disk: self.root.to_string_lossy().to_string(),
|
volume: self.volume.to_string(),
|
||||||
// volume: self.volume.to_string(),
|
path: self.path.to_string(),
|
||||||
// path: self.path.to_string(),
|
offset: offset.try_into().unwrap(),
|
||||||
// offset: offset.try_into().unwrap(),
|
// length: length.try_into().unwrap(),
|
||||||
// length: length.try_into().unwrap(),
|
length: 0,
|
||||||
// };
|
};
|
||||||
// self.tx.send(request).await?;
|
self.tx.send(request).await?;
|
||||||
|
|
||||||
// if let Some(resp) = self.resp_stream.next().await {
|
if let Some(resp) = self.resp_stream.next().await {
|
||||||
// let resp = resp?;
|
let resp = resp?;
|
||||||
// if resp.success {
|
if resp.success {
|
||||||
// info!("read at stream success");
|
info!("read at stream success");
|
||||||
// Ok((resp.data, resp.read_size.try_into().unwrap()))
|
|
||||||
// } else {
|
buf.copy_from_slice(&resp.data);
|
||||||
// let error_info = resp.error_info.unwrap_or("".to_string());
|
|
||||||
// info!("read at stream failed: {}", error_info);
|
Ok(resp.read_size.try_into().unwrap())
|
||||||
// Err(Error::from_string(error_info))
|
} else {
|
||||||
// }
|
let error_info = resp.error_info.unwrap_or("".to_string());
|
||||||
// } else {
|
info!("read at stream failed: {}", error_info);
|
||||||
// let error_info = "can not get response";
|
Err(Error::from_string(error_info))
|
||||||
// info!("read at stream failed: {}", error_info);
|
}
|
||||||
// Err(Error::from_string(error_info))
|
} else {
|
||||||
// }
|
let error_info = "can not get response";
|
||||||
|
info!("read at stream failed: {}", error_info);
|
||||||
|
Err(Error::from_string(error_info))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async fn seek(&mut self, offset: usize) -> Result<()> {
|
async fn seek(&mut self, offset: usize) -> Result<()> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
|||||||
Reference in New Issue
Block a user