summaryrefslogtreecommitdiff
path: root/rola-utils
diff options
context:
space:
mode:
Diffstat (limited to 'rola-utils')
-rw-r--r--rola-utils/functions/src/copy_with_temp_rename/async.rs31
-rw-r--r--rola-utils/functions/src/copy_with_temp_rename/sync.rs31
-rw-r--r--rola-utils/functions/src/test_sandbox.rs4
3 files changed, 26 insertions, 40 deletions
diff --git a/rola-utils/functions/src/copy_with_temp_rename/async.rs b/rola-utils/functions/src/copy_with_temp_rename/async.rs
index 83275a1..33f7693 100644
--- a/rola-utils/functions/src/copy_with_temp_rename/async.rs
+++ b/rola-utils/functions/src/copy_with_temp_rename/async.rs
@@ -35,29 +35,23 @@ async fn internal_copy_with_temp_rename(src: &Path, dst: &Path) -> io::Result<()
}
}
(Err(e), _) | (_, Err(e)) => {
- return Err(io::Error::new(
- io::ErrorKind::Other,
- format!(
- "failed to canonicalize paths (src: {}, dst: {}): {}",
- src.display(),
- dst.display(),
- e
- ),
- ));
+ return Err(io::Error::other(format!(
+ "failed to canonicalize paths (src: {}, dst: {}): {}",
+ src.display(),
+ dst.display(),
+ e
+ )));
}
}
} else {
// dst doesn't exist yet, so it cannot be the same file as src
// If src canonicalization fails, propagate the error
let _ = src_canonical.map_err(|e| {
- io::Error::new(
- io::ErrorKind::Other,
- format!(
- "failed to canonicalize source path (src: {}): {}",
- src.display(),
- e
- ),
- )
+ io::Error::other(format!(
+ "failed to canonicalize source path (src: {}): {}",
+ src.display(),
+ e
+ ))
})?;
}
@@ -215,8 +209,7 @@ async fn atomic_create_temp(dir: &Path, base: &str) -> io::Result<PathBuf> {
}
}
- Err(io::Error::new(
- io::ErrorKind::Other,
+ Err(io::Error::other(
"exceeded max attempts to create temp file",
))
}
diff --git a/rola-utils/functions/src/copy_with_temp_rename/sync.rs b/rola-utils/functions/src/copy_with_temp_rename/sync.rs
index cdbe3db..18e0fcf 100644
--- a/rola-utils/functions/src/copy_with_temp_rename/sync.rs
+++ b/rola-utils/functions/src/copy_with_temp_rename/sync.rs
@@ -28,29 +28,23 @@ fn internal_copy_with_temp_rename(src: &Path, dst: &Path) -> io::Result<()> {
}
}
(Err(e), _) | (_, Err(e)) => {
- return Err(io::Error::new(
- io::ErrorKind::Other,
- format!(
- "failed to canonicalize paths (src: {}, dst: {}): {}",
- src.display(),
- dst.display(),
- e
- ),
- ));
+ return Err(io::Error::other(format!(
+ "failed to canonicalize paths (src: {}, dst: {}): {}",
+ src.display(),
+ dst.display(),
+ e
+ )));
}
}
} else {
// dst doesn't exist yet, so it cannot be the same file as src
// If src canonicalization fails, propagate the error
let _ = src_canonical.map_err(|e| {
- io::Error::new(
- io::ErrorKind::Other,
- format!(
- "failed to canonicalize source path (src: {}): {}",
- src.display(),
- e
- ),
- )
+ io::Error::other(format!(
+ "failed to canonicalize source path (src: {}): {}",
+ src.display(),
+ e
+ ))
})?;
}
@@ -202,8 +196,7 @@ fn atomic_create_temp(dir: &Path, base: &str) -> io::Result<PathBuf> {
}
}
- Err(io::Error::new(
- io::ErrorKind::Other,
+ Err(io::Error::other(
"exceeded max attempts to create temp file",
))
}
diff --git a/rola-utils/functions/src/test_sandbox.rs b/rola-utils/functions/src/test_sandbox.rs
index e0065f6..2705389 100644
--- a/rola-utils/functions/src/test_sandbox.rs
+++ b/rola-utils/functions/src/test_sandbox.rs
@@ -73,9 +73,9 @@ fn try_clear_contents(path: &Path) -> std::io::Result<()> {
for entry in fs::read_dir(path)? {
let entry = entry?;
if entry.file_type()?.is_dir() {
- fs::remove_dir_all(&entry.path())?;
+ fs::remove_dir_all(entry.path())?;
} else {
- fs::remove_file(&entry.path())?;
+ fs::remove_file(entry.path())?;
}
}
}