From 58994e6331e45301d65e8ef5c5a12501998d7e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Thu, 22 Aug 2024 11:10:34 +0200 Subject: [PATCH] fix: Remove unneded idb dependency (#30) --- Cargo.lock | 1 - Cargo.toml | 3 +-- src/indexed_db_blockstore.rs | 8 +------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1af8350..242c32c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,7 +145,6 @@ version = "0.6.1" dependencies = [ "cid", "dashmap", - "idb", "js-sys", "lru", "multihash", diff --git a/Cargo.toml b/Cargo.toml index 099a5a5..3da8a6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ tokio = { version = "1.29.0", features = ["macros", "rt"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] js-sys = { version = "0.3.68", optional = true } rexie = { version = "0.6.1", optional = true } -idb = { version = "0.6.2", optional = true } wasm-bindgen = { version = "0.2.91", optional = true } [dev-dependencies] @@ -47,7 +46,7 @@ multihash-codetable = { version = "0.1.1", features = ["digest", "sha2"] } wasm-bindgen-test = "0.3.41" [features] -indexeddb = ["dep:js-sys", "dep:rexie", "dep:wasm-bindgen", "dep:idb"] +indexeddb = ["dep:js-sys", "dep:rexie", "dep:wasm-bindgen"] lru = ["dep:lru"] redb = ["dep:redb", "dep:tokio"] sled = ["dep:sled", "dep:tokio"] diff --git a/src/indexed_db_blockstore.rs b/src/indexed_db_blockstore.rs index 803cd7e..7c0b39d 100644 --- a/src/indexed_db_blockstore.rs +++ b/src/indexed_db_blockstore.rs @@ -135,14 +135,8 @@ impl From for Error { } } -impl From for Error { - fn from(value: idb::Error) -> Self { - Error::FatalDatabaseError(value.to_string()) - } -} - async fn has_key(store: &Store, key: &JsValue) -> Result { - let key_range = KeyRange::only(key)?; + let key_range = KeyRange::only(key).map_err(rexie::Error::IdbError)?; let count = store.count(Some(key_range)).await?; Ok(count > 0) }