From a27de5588262ed70d887cbfdb1aed9b32b499d1d Mon Sep 17 00:00:00 2001 From: hosted-fornet Date: Mon, 14 Oct 2024 20:42:29 -0700 Subject: [PATCH] fix bugs --- Cargo.lock | 64 +++++++++--------------------------- kinode/src/kernel/process.rs | 2 +- kinode/src/kv.rs | 2 +- kinode/src/main.rs | 9 +---- kinode/src/sqlite.rs | 13 ++------ kinode/src/state.rs | 4 +-- kinode/src/vfs.rs | 2 +- 7 files changed, 23 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f010e0d0..9b540043 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1409,7 +1409,7 @@ dependencies = [ "anyhow", "clap", "fs-err", - "kit 0.7.7", + "kit", "serde_json", "tokio", "walkdir", @@ -3670,6 +3670,7 @@ dependencies = [ "open", "public-ip", "rand 0.8.5", + "regex", "reqwest", "ring", "rmp-serde", @@ -3748,43 +3749,6 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "kit" -version = "0.7.6" -source = "git+https://github.com/kinode-dao/kit?tag=v0.7.6#da6676d79dfdaf47c00ce1d24874fd52de44f717" -dependencies = [ - "alloy 0.1.4", - "alloy-sol-macro", - "alloy-sol-types", - "anyhow", - "base64 0.21.7", - "cargo_metadata", - "clap", - "color-eyre", - "dirs 5.0.1", - "fs-err", - "git2", - "hex", - "kinode_process_lib 0.9.2", - "nix 0.27.1", - "regex", - "reqwest", - "rpassword", - "semver 1.0.23", - "serde", - "serde_json", - "sha2", - "tokio", - "toml", - "tracing", - "tracing-appender", - "tracing-error", - "tracing-subscriber", - "walkdir", - "wit-bindgen", - "zip 0.6.6", -] - [[package]] name = "kit" version = "0.7.7" @@ -3861,13 +3825,15 @@ name = "lib" version = "0.9.7" dependencies = [ "alloy 0.2.1", - "kit 0.7.6", + "anyhow", "lazy_static", "rand 0.8.5", + "reqwest", "ring", "rusqlite", "serde", "serde_json", + "sha2", "thiserror", "tokio", "wasmtime", @@ -4778,7 +4744,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_xorshift 0.3.0", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -5074,14 +5040,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -5095,13 +5061,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -5112,9 +5078,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" diff --git a/kinode/src/kernel/process.rs b/kinode/src/kernel/process.rs index f6f5cbfe..72fa8956 100644 --- a/kinode/src/kernel/process.rs +++ b/kinode/src/kernel/process.rs @@ -178,7 +178,7 @@ async fn make_component( async fn make_component_v0( engine: Engine, wasm_bytes: &[u8], - home_directory_path: String, + home_directory_path: PathBuf, process_state: ProcessState, ) -> anyhow::Result<(ProcessV0, Store, MemoryOutputPipe)> { let component = diff --git a/kinode/src/kv.rs b/kinode/src/kv.rs index 106ec655..055b03c9 100644 --- a/kinode/src/kv.rs +++ b/kinode/src/kv.rs @@ -110,7 +110,7 @@ pub async fn kv( let mut state = KvState::new(our, send_to_terminal, send_to_loop, home_directory_path); - if let Err(e) = fs::create_dir_all(&state.kv_path).await { + if let Err(e) = fs::create_dir_all(&*state.kv_path).await { panic!("failed creating kv dir! {e:?}"); } diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 0db5ce5d..f040e3a6 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -9,7 +9,7 @@ use lib::types::core::{ #[cfg(feature = "simulation-mode")] use ring::{rand::SystemRandom, signature, signature::KeyPair}; use std::env; -std::path::Path; +use std::path::Path; use std::sync::Arc; use tokio::sync::mpsc; @@ -665,13 +665,6 @@ pub async fn simulate_node( } } -async fn create_home_directory(home_directory_path: &str) { - if let Err(e) = tokio::fs::create_dir_all(home_directory_path).await { - panic!("failed to create home directory: {e:?}"); - } - println!("home at {home_directory_path}\r"); -} - /// build the command line interface for kinode /// fn build_command() -> Command { diff --git a/kinode/src/sqlite.rs b/kinode/src/sqlite.rs index 94e1484e..8e53d035 100644 --- a/kinode/src/sqlite.rs +++ b/kinode/src/sqlite.rs @@ -78,7 +78,7 @@ impl SqliteState { fs::create_dir_all(&db_path).await?; - let db_file_path = format!("{}/{}.db", db_path, db); + let db_file_path = format!("{}.db", db); let db_conn = Connection::open(db_file_path)?; let _ = db_conn.execute("PRAGMA journal_mode=WAL", []); @@ -120,7 +120,7 @@ pub async fn sqlite( let mut state = SqliteState::new(our, send_to_terminal, send_to_loop, home_directory_path); - if let Err(e) = fs::create_dir_all(&state.sqlite_path).await { + if let Err(e) = fs::create_dir_all(&*state.sqlite_path).await { panic!("failed creating sqlite dir! {e:?}"); } @@ -522,15 +522,6 @@ async fn check_caps( .remove_db(request.package_id.clone(), request.db.clone()) .await; - #[cfg(unix)] - let db_path = state.sqlite_path - .join(format!("{}", request.package_id)) - .join(&request.db); - #[cfg(target_os = "windows")] - let db_path = state.sqlite_path - .join(format!("{}_{}", request.package_id._package(), request.package_id._publisher())) - .join(&request.db); - Ok(()) } SqliteAction::Backup => { diff --git a/kinode/src/state.rs b/kinode/src/state.rs index eabeb295..da4ec353 100644 --- a/kinode/src/state.rs +++ b/kinode/src/state.rs @@ -250,7 +250,7 @@ async fn handle_request( } } StateAction::Backup => { - let checkpoint_dir = home_directory_path.join("kernel".join("backup"); + let checkpoint_dir = home_directory_path.join("kernel").join("backup"); if checkpoint_dir.exists() { fs::remove_dir_all(&checkpoint_dir).await?; } @@ -422,7 +422,7 @@ async fn bootstrap( // save the zip itself inside pkg folder, for sharing with others let mut zip_file = - fs::File::create(pkg_path.join(format!("{}.zip", &our_drive_name)).await?; + fs::File::create(pkg_path.join(format!("{}.zip", &our_drive_name))).await?; let package_zip_bytes = package.clone().into_inner().into_inner(); zip_file.write_all(&package_zip_bytes).await?; diff --git a/kinode/src/vfs.rs b/kinode/src/vfs.rs index 315f7780..6743d685 100644 --- a/kinode/src/vfs.rs +++ b/kinode/src/vfs.rs @@ -667,7 +667,7 @@ async fn handle_request( Ok(()) } -async fn parse_package_and_drive( +fn parse_package_and_drive( path: &str, vfs_path: &PathBuf, ) -> Result<(PackageId, String, PathBuf), VfsError> {