From ba04083d2cce2d782ad7379d05a936d7aa86f507 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 21 Nov 2021 14:56:29 +0100 Subject: [PATCH] Update rmp-ipc and add more tracing Signed-off-by: trivernis --- mediarepo-api/Cargo.toml | 4 ++-- mediarepo-api/src/tauri_plugin/custom_schemes.rs | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mediarepo-api/Cargo.toml b/mediarepo-api/Cargo.toml index a49d486..86f77d5 100644 --- a/mediarepo-api/Cargo.toml +++ b/mediarepo-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mediarepo-api" -version = "0.11.1" +version = "0.12.0" edition = "2018" license = "gpl-3" @@ -10,7 +10,7 @@ license = "gpl-3" tracing = "0.1.29" thiserror = "1.0.30" async-trait = {version = "0.1.51", optional=true} -rmp-ipc = {version = "0.10.0", optional=true} +rmp-ipc = {version = "0.11.0", optional=true} parking_lot = {version="0.11.2", optional=true} serde_json = {version="1.0.68", optional=true} directories = {version="4.0.1", optional=true} diff --git a/mediarepo-api/src/tauri_plugin/custom_schemes.rs b/mediarepo-api/src/tauri_plugin/custom_schemes.rs index 29695eb..d02f25f 100644 --- a/mediarepo-api/src/tauri_plugin/custom_schemes.rs +++ b/mediarepo-api/src/tauri_plugin/custom_schemes.rs @@ -32,6 +32,7 @@ fn build_uri_runtime() -> PluginResult { Ok(runtime) } +#[tracing::instrument(level = "debug", skip_all)] fn once_scheme(app: &AppHandle, request: &Request) -> Result { let buf_state = app.state::(); let resource_key = request.uri().trim_start_matches("once://"); @@ -51,17 +52,20 @@ fn once_scheme(app: &AppHandle, request: &Request) -> Result(app: &AppHandle, request: &Request) -> Result { let api_state = app.state::(); let buf_state = app.state::(); let hash = request.uri().trim_start_matches("content://"); if let Some(buffer) = buf_state.get_entry(hash) { + tracing::debug!("Fetching content from cache"); ResponseBuilder::new() .status(200) .mimetype(&buffer.mime) .body(buffer.buf) } else { + tracing::debug!("Fetching content from daemon"); let api = api_state.api().await?; let file = api .file @@ -72,6 +76,7 @@ async fn content_scheme(app: &AppHandle, request: &Request) -> Re .file .read_file(FileIdentifier::Hash(hash.to_string())) .await?; + tracing::debug!("Received {} content bytes", bytes.len()); buf_state.add_entry(hash.to_string(), mime.clone(), bytes.clone()); ResponseBuilder::new() .mimetype(&mime) @@ -80,6 +85,7 @@ async fn content_scheme(app: &AppHandle, request: &Request) -> Re } } +#[tracing::instrument(level = "debug", skip_all)] async fn thumb_scheme(app: &AppHandle, request: &Request) -> Result { let api_state = app.state::(); let buf_state = app.state::(); @@ -104,11 +110,13 @@ async fn thumb_scheme(app: &AppHandle, request: &Request) -> Resu .unwrap_or(250); if let Some(buffer) = buf_state.get_entry(request.uri()) { + tracing::debug!("Fetching content from cache"); ResponseBuilder::new() .status(200) .mimetype(&buffer.mime) .body(buffer.buf) } else { + tracing::debug!("Fetching content from daemon"); let api = api_state.api().await?; let (thumb, bytes) = api .file @@ -118,6 +126,7 @@ async fn thumb_scheme(app: &AppHandle, request: &Request) -> Resu ((height as f32 * 1.2) as u32, (width as f32 * 1.2) as u32), ) .await?; + tracing::debug!("Received {} content bytes", bytes.len()); buf_state.add_entry( request.uri().to_string(), thumb.mime_type.clone(),