diff --git a/src/db.rs b/src/db.rs index b5e913a..4083ddc 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,21 +1,17 @@ use metrics::counter; +use std::fmt::Debug; use serde::{Deserialize, Serialize}; -use std::{fmt::Debug, sync::LazyLock, time::Instant}; use surrealdb::{ engine::remote::ws::{Client, Ws}, opt::auth::Root, sql::Thing, Surreal, }; -use tokio::sync::Mutex; use tracing::{error, instrument, trace}; use url::Url; use crate::Config; -static LOCK: LazyLock> = LazyLock::new(|| Mutex::new(true)); - -const TIME_SPENT_ON_LOCK: &str = "surql_lock_waiting_ms"; const STORE: &str = "surql_store_calls"; #[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Hash)] @@ -57,14 +53,6 @@ impl Website { counter!(STORE).increment(1); let mut things = Vec::with_capacity(all.len()); - // TODO this only allows for one thread to be in the database at a time. - // This is currently required since otherwise we get write errors. - // If the default `crawled` is set to false, we might not need to write any more - // than just the name. `accessed_at` is fun but not needed. - let now = Instant::now(); - let lock = LOCK.lock().await; - counter!(TIME_SPENT_ON_LOCK).increment(now.elapsed().as_millis() as u64); - match db .query( "INSERT INTO website $array @@ -85,7 +73,6 @@ impl Website { error!("{:?}", err); } } - drop(lock); things } } diff --git a/src/filesystem.rs b/src/filesystem.rs index 85fcf30..46c1af3 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -1,7 +1,7 @@ use std::{ffi::OsStr, path::PathBuf}; use tokio::fs; -use tracing::{debug, error, info, instrument, trace, warn}; +use tracing::{debug, error, instrument, trace, warn}; use url::Url; #[instrument(skip(data))] @@ -21,7 +21,7 @@ pub async fn store(data: &str, url: &Url) { (url_path.clone(), "index.html".into()) }; - info!("Writing at: {:?} {:?}", basepath, filename); + debug!("Writing at: {:?} {:?}", basepath, filename); // create the folders if let Err(err) = fs::create_dir_all(&basepath).await {