From 75ec650f080ac66e98d8b848118dc2349ca70aa8 Mon Sep 17 00:00:00 2001 From: Igor Zinkovsky Date: Tue, 28 Nov 2023 21:04:07 -0800 Subject: [PATCH] chore(ext/kv): update denokv crates (#21357) --- Cargo.lock | 13 +++++++------ Cargo.toml | 6 +++--- ext/kv/sqlite.rs | 10 ++++++---- runtime/errors.rs | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f799eb8b4c..46a85b3210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1704,9 +1704,9 @@ dependencies = [ [[package]] name = "denokv_proto" -version = "0.2.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8952fb8c38c1dcd796d49b00030afb74aa184160ae86817b72a32a994c8e16f0" +checksum = "dd501a6b10a8b7fe7e605cafe4aad1d266ed0791b788dab78889df14b1a23e5f" dependencies = [ "anyhow", "async-trait", @@ -1720,9 +1720,9 @@ dependencies = [ [[package]] name = "denokv_remote" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfc8447324d783b01e215bd5040ff9149c34d9715c7b7b5080dd648ebf1148a" +checksum = "7d94fd3da7d1fa9ef1515bf3bc5b2fe75389edb3f15e9445e345679fda44987c" dependencies = [ "anyhow", "async-trait", @@ -1742,9 +1742,9 @@ dependencies = [ [[package]] name = "denokv_sqlite" -version = "0.2.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ec76b691ff069f14e56e3e053c2b2163540b27e4b60179f2b120064a7e4960d" +checksum = "c2d2ab5fe45079dc41ab76549bb9fc3aeb9be4e54fddbdfb16a779db4a0b38df" dependencies = [ "anyhow", "async-trait", @@ -1756,6 +1756,7 @@ dependencies = [ "rand", "rusqlite", "serde_json", + "thiserror", "tokio", "uuid", ] diff --git a/Cargo.toml b/Cargo.toml index 1c68420469..dcbcfa1c3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,10 +49,10 @@ test_util = { path = "./test_util" } deno_lockfile = "0.17.2" deno_media_type = { version = "0.1.1", features = ["module_specifier"] } -denokv_proto = "0.2.1" +denokv_proto = "0.4.0" # denokv_sqlite brings in bundled sqlite if we don't disable the default features -denokv_sqlite = { default-features = false, version = "0.2.1" } -denokv_remote = "0.2.3" +denokv_sqlite = { default-features = false, version = "0.4.0" } +denokv_remote = "0.4.0" # exts deno_broadcast_channel = { version = "0.119.0", path = "./ext/broadcast_channel" } diff --git a/ext/kv/sqlite.rs b/ext/kv/sqlite.rs index b4e251f962..2e7b97126f 100644 --- a/ext/kv/sqlite.rs +++ b/ext/kv/sqlite.rs @@ -18,7 +18,7 @@ use deno_core::error::AnyError; use deno_core::unsync::spawn_blocking; use deno_core::OpState; use deno_node::PathClean; -pub use denokv_sqlite::TypeError; +pub use denokv_sqlite::SqliteBackendError; use rand::RngCore; use rand::SeedableRng; use rusqlite::OpenFlags; @@ -95,14 +95,16 @@ impl DatabaseHandler for SqliteDbHandler

{ (Some(path), _) => { let flags = OpenFlags::default().difference(OpenFlags::SQLITE_OPEN_URI); - let resolved_path = canonicalize_path(&PathBuf::from(path))?; + let resolved_path = canonicalize_path(&PathBuf::from(path)) + .map_err(|_| SqliteBackendError::DatabaseClosed)?; ( rusqlite::Connection::open_with_flags(path, flags)?, Some(resolved_path), ) } (None, Some(path)) => { - std::fs::create_dir_all(path)?; + std::fs::create_dir_all(path) + .map_err(|_| SqliteBackendError::DatabaseClosed)?; let path = path.join("kv.sqlite3"); (rusqlite::Connection::open(path.clone())?, Some(path)) } @@ -110,7 +112,7 @@ impl DatabaseHandler for SqliteDbHandler

{ conn.pragma_update(None, "journal_mode", "wal")?; - Ok::<_, AnyError>((conn, queue_waker_key)) + Ok::<_, SqliteBackendError>((conn, queue_waker_key)) }) }) .await diff --git a/runtime/errors.rs b/runtime/errors.rs index f48f01246e..2061a5e0b9 100644 --- a/runtime/errors.rs +++ b/runtime/errors.rs @@ -212,7 +212,7 @@ pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> { .map(get_url_parse_error_class) }) .or_else(|| { - e.downcast_ref::() + e.downcast_ref::() .map(|_| "TypeError") }) .or_else(|| {