diff --git a/Cargo.toml b/Cargo.toml index 5547bb0..a11950d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,3 @@ members = [ "tilekit", "tiles", ] - - -[workspace.lints.clippy] -pedantic = "warn" diff --git a/tiles/src/core/accounts.rs b/tiles/src/core/accounts.rs index 1f57765..ef425f4 100644 --- a/tiles/src/core/accounts.rs +++ b/tiles/src/core/accounts.rs @@ -353,7 +353,7 @@ fn parse_user_from_row(row: &Row<'_>) -> Result { updated_at: updated_at as u64, }) } -/// Gets a peer by its DID +/// Gets a user account by its DID pub fn get_user_info(conn: &Connection, did: &str) -> Result { let mut fetch_user = conn.prepare("select id, user_id, username, account_type, active_profile, root, created_at, updated_at from users where user_id = ?1")?; diff --git a/tiles/src/core/chats.rs b/tiles/src/core/chats.rs index 0097a50..836534a 100644 --- a/tiles/src/core/chats.rs +++ b/tiles/src/core/chats.rs @@ -199,12 +199,13 @@ pub fn apply_delta(chat_conn: &mut Connection, delta_chats: &Vec) -> Resu Err(rusqlite::Error::SqliteFailure(_, Some(reason))) if reason == "UNIQUE constraint failed: chats.id" => { - log::warn!( + log::error!( "err in writing row {:?}, already exists, skipping", &chat.id ); } - _ => (), + Err(err) => log::error!("err in writing row due to {:?}", err), + Ok(_) => (), } } } diff --git a/tiles/src/core/network/mod.rs b/tiles/src/core/network/mod.rs index a712299..c8ad438 100644 --- a/tiles/src/core/network/mod.rs +++ b/tiles/src/core/network/mod.rs @@ -47,6 +47,9 @@ use crate::core::{ use owo_colors::OwoColorize; use sha2::{Digest, Sha256}; +// 50 mb +const MAX_DOWNLOADED_BYTES: usize = 50 * 1024 * 1024; + const DEVICE_LINK_LOCAL_TOPIC: &str = "com.tilesprivacy.tiles.link"; #[derive(serde::Serialize, serde::Deserialize)] struct NetworkMessage { @@ -424,6 +427,7 @@ pub async fn sync(did: Option) -> Result<()> { let mdns = address_lookup::mdns::MdnsAddressLookup::builder().build(endpoint.id())?; endpoint.address_lookup()?.add(mdns.clone()); } + let tx = create_sync_channel(); if let Some(receiver_did) = did { // INITIATOR BLOCK @@ -735,8 +739,16 @@ async fn on_sync_send_delta_info( .await?; let data = store.blobs().get_bytes(ticket.hash()).await?; - info!("Downloaded data diff"); + + if data.len() > MAX_DOWNLOADED_BYTES { + log::error!( + "Downloaded delta is greater than {}, skipping the sync", + MAX_DOWNLOADED_BYTES + ); + return Ok(()); + } + let (sendx, recvx) = oneshot::channel(); let sync_op_msg = SyncOp::ApplyDelta { delta: data.to_vec(),