diff --git a/Cargo.lock b/Cargo.lock index 9d10ff4..6d66b26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,6 +52,18 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "base64" version = "0.21.7" @@ -71,12 +83,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] -name = "block-buffer" -version = "0.10.4" +name = "blake3" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" dependencies = [ - "generic-array", + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", ] [[package]] @@ -162,6 +178,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + [[package]] name = "core-foundation" version = "0.9.4" @@ -178,35 +200,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "cpufeatures" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "directories" version = "5.0.1" @@ -380,16 +373,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.16" @@ -444,12 +427,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "http" version = "0.2.12" @@ -723,15 +700,14 @@ dependencies = [ name = "noentropy" version = "1.0.4" dependencies = [ + "blake3", "clap", "colored", "directories", "futures", - "hex", "reqwest", "serde", "serde_json", - "sha2", "tempfile", "thiserror 2.0.17", "tokio", @@ -1013,17 +989,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "shlex" version = "1.3.0" @@ -1307,12 +1272,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typenum" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" - [[package]] name = "unicode-ident" version = "1.0.22" @@ -1349,12 +1308,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "walkdir" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index f3f27b3..b9bc0b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,15 +4,14 @@ version = "1.0.4" edition = "2024" [dependencies] +blake3 = "1.5" clap = { version = "4.5.23", features = ["derive"] } colored = "3.0.0" directories = "5.0.1" futures = "0.3.31" -hex = "0.4.3" reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] } serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.145" -sha2 = "0.10.8" thiserror = "2.0.11" tokio = { version = "1.48.0", features = ["rt-multi-thread", "macros", "sync", "time"] } toml = "0.8.19" @@ -20,3 +19,6 @@ walkdir = "2.5.0" [dev-dependencies] tempfile = "3.15" + +[profile.release] +debug = true diff --git a/src/settings/config.rs b/src/settings/config.rs index 557dd6e..e6fcdd8 100644 --- a/src/settings/config.rs +++ b/src/settings/config.rs @@ -121,7 +121,7 @@ pub fn get_or_prompt_api_key() -> Result> { Ok(api_key) } -pub fn change_and_prompt_api_key() -> Result> { +pub fn change_and_prompt_api_key() -> Result<(), Box> { println!(); println!("{}", "🔑 NoEntropy Configuration".bold().cyan()); println!("{}", "─────────────────────────────".cyan()); @@ -129,11 +129,11 @@ pub fn change_and_prompt_api_key() -> Result> let api_key = Prompter::prompt_api_key()?; let mut config = Config::load().unwrap_or_default(); - config.api_key = api_key.clone(); + config.api_key = api_key; config.save()?; println!(); - Ok(api_key) + Ok(()) } pub fn get_or_prompt_download_folder() -> Result> { diff --git a/src/storage/cache.rs b/src/storage/cache.rs index ed80424..3f54b88 100644 --- a/src/storage/cache.rs +++ b/src/storage/cache.rs @@ -1,6 +1,6 @@ use crate::models::{CacheEntry, FileMetadata, OrganizationPlan}; +use blake3::Hasher; use serde::{Deserialize, Serialize}; -use sha2::{Digest, Sha256}; use std::collections::HashMap; use std::fs; use std::path::Path; @@ -141,13 +141,13 @@ impl Cache { let mut sorted_filenames = filenames.to_vec(); sorted_filenames.sort(); - let mut hasher = Sha256::new(); + let mut hasher = Hasher::new(); for filename in &sorted_filenames { hasher.update(filename.as_bytes()); hasher.update(b"|"); } - hex::encode(hasher.finalize()) + hasher.finalize().to_hex().to_string() } fn get_file_metadata(file_path: &Path) -> Result> {