Xuanwo commented on code in PR #4944:
URL: https://github.com/apache/opendal/pull/4944#discussion_r1701501085
##########
core/src/services/monoiofs/backend.rs:
##########
@@ -121,8 +124,72 @@ impl Access for MonoiofsBackend {
am.set_scheme(Scheme::Monoiofs)
.set_root(&self.core.root().to_string_lossy())
.set_native_capability(Capability {
+ stat: true,
+ read: true,
+ write: true,
+ delete: true,
..Default::default()
});
am.into()
}
+
+ async fn stat(&self, path: &str, _args: OpStat) -> Result<RpStat> {
+ let path = self.core.prepare_path(path);
+ // TODO: borrowed from FsBackend because statx support for monoio
+ // is not released yet, but stat capability is required for read
+ // and write
+ let meta = tokio::fs::metadata(&path).await.map_err(new_std_io_error)?;
Review Comment:
I didn't feel good about introducing `tokio` here. I believe we can wait for
next monoio release instead.
##########
core/src/services/monoiofs/backend.rs:
##########
@@ -121,8 +124,72 @@ impl Access for MonoiofsBackend {
am.set_scheme(Scheme::Monoiofs)
.set_root(&self.core.root().to_string_lossy())
.set_native_capability(Capability {
+ stat: true,
+ read: true,
+ write: true,
+ delete: true,
..Default::default()
});
am.into()
}
+
+ async fn stat(&self, path: &str, _args: OpStat) -> Result<RpStat> {
+ let path = self.core.prepare_path(path);
+ // TODO: borrowed from FsBackend because statx support for monoio
+ // is not released yet, but stat capability is required for read
+ // and write
+ let meta = tokio::fs::metadata(&path).await.map_err(new_std_io_error)?;
+ let mode = if meta.is_dir() {
+ EntryMode::DIR
+ } else if meta.is_file() {
+ EntryMode::FILE
+ } else {
+ EntryMode::Unknown
+ };
+ let m = Metadata::new(mode)
+ .with_content_length(meta.len())
+ .with_last_modified(
+ meta.modified()
+ .map(DateTime::from)
+ .map_err(new_std_io_error)?,
+ );
+ Ok(RpStat::new(m))
+ }
+
+ async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead,
Self::Reader)> {
+ let path = self.core.prepare_path(path);
+ let reader = MonoiofsReader::new(self.core.clone(), path,
args.range()).await?;
+ Ok((RpRead::default(), reader))
+ }
+
+ async fn write(&self, path: &str, _args: OpWrite) -> Result<(RpWrite,
Self::Writer)> {
+ // TODO: create parent directory before write
+ let path = self.core.prepare_path(path);
+ let writer = MonoiofsWriter::new(self.core.clone(), path).await?;
+ Ok((RpWrite::default(), writer))
+ }
+
+ async fn delete(&self, path: &str, _args: OpDelete) -> Result<RpDelete> {
+ let path = self.core.prepare_path(path);
+ // TODO: borrowed from FsBackend because monoio doesn't support unlink,
Review Comment:
Would you like to help implement this? I'm willing to help review and get it
merged on upstream first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]