mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 19:16:17 +00:00
fix(ecstore): fs block_in_place
This commit is contained in:
+21
-15
@@ -109,7 +109,7 @@ pub async fn access(path: impl AsRef<Path>) -> io::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn access_std(path: impl AsRef<Path>) -> io::Result<()> {
|
pub fn access_std(path: impl AsRef<Path>) -> io::Result<()> {
|
||||||
std::fs::metadata(path)?;
|
tokio::task::block_in_place(|| std::fs::metadata(path))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ pub async fn lstat(path: impl AsRef<Path>) -> io::Result<Metadata> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn lstat_std(path: impl AsRef<Path>) -> io::Result<Metadata> {
|
pub fn lstat_std(path: impl AsRef<Path>) -> io::Result<Metadata> {
|
||||||
std::fs::metadata(path)
|
tokio::task::block_in_place(|| std::fs::metadata(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn make_dir_all(path: impl AsRef<Path>) -> io::Result<()> {
|
pub async fn make_dir_all(path: impl AsRef<Path>) -> io::Result<()> {
|
||||||
@@ -146,21 +146,27 @@ pub async fn remove_all(path: impl AsRef<Path>) -> io::Result<()> {
|
|||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
pub fn remove_std(path: impl AsRef<Path>) -> io::Result<()> {
|
pub fn remove_std(path: impl AsRef<Path>) -> io::Result<()> {
|
||||||
let meta = std::fs::metadata(path.as_ref())?;
|
let path = path.as_ref();
|
||||||
if meta.is_dir() {
|
tokio::task::block_in_place(|| {
|
||||||
std::fs::remove_dir(path.as_ref())
|
let meta = std::fs::metadata(path)?;
|
||||||
} else {
|
if meta.is_dir() {
|
||||||
std::fs::remove_file(path.as_ref())
|
std::fs::remove_dir(path)
|
||||||
}
|
} else {
|
||||||
|
std::fs::remove_file(path)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_all_std(path: impl AsRef<Path>) -> io::Result<()> {
|
pub fn remove_all_std(path: impl AsRef<Path>) -> io::Result<()> {
|
||||||
let meta = std::fs::metadata(path.as_ref())?;
|
let path = path.as_ref();
|
||||||
if meta.is_dir() {
|
tokio::task::block_in_place(|| {
|
||||||
std::fs::remove_dir_all(path.as_ref())
|
let meta = std::fs::metadata(path)?;
|
||||||
} else {
|
if meta.is_dir() {
|
||||||
std::fs::remove_file(path.as_ref())
|
std::fs::remove_dir_all(path)
|
||||||
}
|
} else {
|
||||||
|
std::fs::remove_file(path)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn mkdir(path: impl AsRef<Path>) -> io::Result<()> {
|
pub async fn mkdir(path: impl AsRef<Path>) -> io::Result<()> {
|
||||||
@@ -172,7 +178,7 @@ pub async fn rename(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn rename_std(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
|
pub fn rename_std(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()> {
|
||||||
std::fs::rename(from, to)
|
tokio::task::block_in_place(|| std::fs::rename(from, to))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
|
|||||||
Reference in New Issue
Block a user