From dc0488cf758a90e6db5d7ae51de7ea228f86730c Mon Sep 17 00:00:00 2001 From: Steven <112043913+stevencartavia@users.noreply.github.com> Date: Fri, 7 Feb 2025 02:51:03 -0600 Subject: [PATCH] feat: remove from fspath conversion for storagelockerr (#14291) --- Cargo.lock | 1 - crates/storage/db/src/lockfile.rs | 5 +++-- crates/storage/errors/Cargo.toml | 1 - crates/storage/errors/src/lockfile.rs | 9 ++++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 653d900094..8a71f8960c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9334,7 +9334,6 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "reth-fs-util", "reth-primitives-traits", "reth-prune-types", "reth-static-file-types", diff --git a/crates/storage/db/src/lockfile.rs b/crates/storage/db/src/lockfile.rs index 15ddee2f0f..c44f88790d 100644 --- a/crates/storage/db/src/lockfile.rs +++ b/crates/storage/db/src/lockfile.rs @@ -86,7 +86,7 @@ impl StorageLockInner { fn new(file_path: PathBuf) -> Result { // Create the directory if it doesn't exist if let Some(parent) = file_path.parent() { - reth_fs_util::create_dir_all(parent)?; + reth_fs_util::create_dir_all(parent).map_err(StorageLockError::other)?; } // Write this process unique identifier (pid & start_time) to file @@ -148,7 +148,8 @@ impl ProcessUID { /// Writes `pid` and `start_time` to a file. fn write(&self, path: &Path) -> Result<(), StorageLockError> { - Ok(reth_fs_util::write(path, format!("{}\n{}", self.pid, self.start_time))?) + reth_fs_util::write(path, format!("{}\n{}", self.pid, self.start_time)) + .map_err(StorageLockError::other) } } diff --git a/crates/storage/errors/Cargo.toml b/crates/storage/errors/Cargo.toml index ece3340c67..24e282605e 100644 --- a/crates/storage/errors/Cargo.toml +++ b/crates/storage/errors/Cargo.toml @@ -12,7 +12,6 @@ workspace = true [dependencies] # reth -reth-fs-util.workspace = true reth-primitives-traits.workspace = true reth-prune-types.workspace = true reth-static-file-types.workspace = true diff --git a/crates/storage/errors/src/lockfile.rs b/crates/storage/errors/src/lockfile.rs index ec276cdce5..3a5cb362b6 100644 --- a/crates/storage/errors/src/lockfile.rs +++ b/crates/storage/errors/src/lockfile.rs @@ -1,5 +1,4 @@ use alloc::string::{String, ToString}; -use reth_fs_util::FsPathError; /// Storage lock error. #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] @@ -12,9 +11,9 @@ pub enum StorageLockError { Other(String), } -/// TODO: turn into variant once `ProviderError` -impl From for StorageLockError { - fn from(error: FsPathError) -> Self { - Self::Other(error.to_string()) +impl StorageLockError { + /// Converts any error into the `Other` variant of `StorageLockError`. + pub fn other(err: E) -> Self { + Self::Other(err.to_string()) } }