This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 536eeb1a chore(core): remove unnecessary path prefix (#2265)
536eeb1a is described below
commit 536eeb1a3c834aa052da945cb3c7933fe848afe2
Author: Morris Tai <[email protected]>
AuthorDate: Wed May 17 00:23:58 2023 -0400
chore(core): remove unnecessary path prefix (#2265)
* chore(core): remove unnecessary path prefix
* chore(core): drop `use` and call full path instead
---
core/src/layers/oteltrace.rs | 2 +-
core/src/raw/oio/read.rs | 4 ++--
core/src/services/fs/backend.rs | 24 +++++++++++++-----------
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/core/src/layers/oteltrace.rs b/core/src/layers/oteltrace.rs
index 4894ad9b..ee01e2ab 100644
--- a/core/src/layers/oteltrace.rs
+++ b/core/src/layers/oteltrace.rs
@@ -308,7 +308,7 @@ impl<R: oio::BlockingRead> oio::BlockingRead for
OtelTraceWrapper<R> {
self.inner.read(buf)
}
- fn seek(&mut self, pos: std::io::SeekFrom) -> Result<u64> {
+ fn seek(&mut self, pos: io::SeekFrom) -> Result<u64> {
self.inner.seek(pos)
}
diff --git a/core/src/raw/oio/read.rs b/core/src/raw/oio/read.rs
index b71b62ef..29987581 100644
--- a/core/src/raw/oio/read.rs
+++ b/core/src/raw/oio/read.rs
@@ -346,7 +346,7 @@ impl<T: BlockingRead + ?Sized> BlockingRead for Box<T> {
}
}
-impl std::io::Read for dyn BlockingRead {
+impl io::Read for dyn BlockingRead {
#[inline]
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let this: &mut dyn BlockingRead = &mut *self;
@@ -355,7 +355,7 @@ impl std::io::Read for dyn BlockingRead {
}
}
-impl std::io::Seek for dyn BlockingRead {
+impl io::Seek for dyn BlockingRead {
#[inline]
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
let this: &mut dyn BlockingRead = &mut *self;
diff --git a/core/src/services/fs/backend.rs b/core/src/services/fs/backend.rs
index 282656d9..3e914f55 100644
--- a/core/src/services/fs/backend.rs
+++ b/core/src/services/fs/backend.rs
@@ -17,7 +17,6 @@
use std::cmp::min;
use std::collections::HashMap;
-use std::io;
use std::io::SeekFrom;
use std::path::Path;
use std::path::PathBuf;
@@ -26,7 +25,6 @@ use async_compat::Compat;
use async_trait::async_trait;
use chrono::DateTime;
use log::debug;
-use tokio::fs;
use uuid::Uuid;
use super::error::parse_io_error;
@@ -157,7 +155,7 @@ impl Builder for FsBuilder {
// If root dir is not exist, we must create it.
if let Err(e) = std::fs::metadata(&root) {
- if e.kind() == io::ErrorKind::NotFound {
+ if e.kind() == std::io::ErrorKind::NotFound {
std::fs::create_dir_all(&root).map_err(|e| {
Error::new(ErrorKind::Unexpected, "create root dir failed")
.with_operation("Builder::build")
@@ -172,7 +170,7 @@ impl Builder for FsBuilder {
// If atomic write dir is not exist, we must create it.
if let Some(d) = &atomic_write_dir {
if let Err(e) = std::fs::metadata(d) {
- if e.kind() == io::ErrorKind::NotFound {
+ if e.kind() == std::io::ErrorKind::NotFound {
std::fs::create_dir_all(d).map_err(|e| {
Error::new(ErrorKind::Unexpected, "create atomic write
dir failed")
.with_operation("Builder::build")
@@ -284,7 +282,9 @@ impl FsBackend {
})?
.to_path_buf();
- fs::create_dir_all(&parent).await.map_err(parse_io_error)?;
+ tokio::fs::create_dir_all(&parent)
+ .await
+ .map_err(parse_io_error)?;
Ok(p)
}
@@ -332,7 +332,9 @@ impl Accessor for FsBackend {
async fn create_dir(&self, path: &str, _: OpCreateDir) ->
Result<RpCreateDir> {
let p = self.root.join(path.trim_end_matches('/'));
- fs::create_dir_all(&p).await.map_err(parse_io_error)?;
+ tokio::fs::create_dir_all(&p)
+ .await
+ .map_err(parse_io_error)?;
Ok(RpCreateDir::default())
}
@@ -351,7 +353,7 @@ impl Accessor for FsBackend {
let p = self.root.join(path.trim_end_matches('/'));
- let mut f = fs::OpenOptions::new()
+ let mut f = tokio::fs::OpenOptions::new()
.read(true)
.open(&p)
.await
@@ -496,9 +498,9 @@ impl Accessor for FsBackend {
match meta {
Ok(meta) => {
if meta.is_dir() {
- fs::remove_dir(&p).await.map_err(parse_io_error)?;
+ tokio::fs::remove_dir(&p).await.map_err(parse_io_error)?;
} else {
- fs::remove_file(&p).await.map_err(parse_io_error)?;
+ tokio::fs::remove_file(&p).await.map_err(parse_io_error)?;
}
Ok(RpDelete::default())
@@ -514,7 +516,7 @@ impl Accessor for FsBackend {
let f = match tokio::fs::read_dir(&p).await {
Ok(rd) => rd,
Err(e) => {
- return if e.kind() == io::ErrorKind::NotFound {
+ return if e.kind() == std::io::ErrorKind::NotFound {
Ok((RpList::default(), None))
} else {
Err(parse_io_error(e))
@@ -699,7 +701,7 @@ impl Accessor for FsBackend {
let f = match std::fs::read_dir(p) {
Ok(rd) => rd,
Err(e) => {
- return if e.kind() == io::ErrorKind::NotFound {
+ return if e.kind() == std::io::ErrorKind::NotFound {
Ok((RpList::default(), None))
} else {
Err(parse_io_error(e))