diff --git a/Cargo.lock b/Cargo.lock index 689c5be..b4e8475 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -301,7 +301,6 @@ dependencies = [ "tokio", "unicode-width 0.1.14", "url", - "urlencoding", ] [[package]] @@ -2544,12 +2543,6 @@ dependencies = [ "serde", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf8_iter" version = "1.0.4" diff --git a/Cargo.toml b/Cargo.toml index 680dfe3..8db9700 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,6 @@ serde = { version = "*", features = ["derive"] } serde_json = { version = "*", default-features = false, features = ["std"] } serde_yaml = { version = "*", default-features = false } quick-xml = { version = "*", features = ["serialize"] } -urlencoding = { version = "*", default-features = false } percent-encoding = { version = "*", default-features = false } regex = { version = "*", default-features = false, features = ["std"] } # CLI diff --git a/src/interpreter/flamegraph.rs b/src/interpreter/flamegraph.rs index b08372e..ac95abb 100644 --- a/src/interpreter/flamegraph.rs +++ b/src/interpreter/flamegraph.rs @@ -10,7 +10,6 @@ use flamelens::ui; use ratatui::Terminal; use ratatui::backend::CrosstermBackend; use std::io; -use urlencoding::encode; pub fn show(block: Columns) -> AppResult<()> { let data = block @@ -72,11 +71,7 @@ pub fn show(block: Columns) -> AppResult<()> { Ok(()) } -pub async fn open_in_speedscope( - block: Columns, - pastila_clickhouse_host: &str, - pastila_url: &str, -) -> Result<()> { +pub async fn share(block: Columns, pastila_clickhouse_host: &str, pastila_url: &str) -> Result<()> { let data = block .rows() .map(|x| { @@ -93,12 +88,9 @@ pub async fn open_in_speedscope( return Err(Error::msg("Flamegraph is empty")); } - let pastila_url = pastila::upload(&data, pastila_clickhouse_host, pastila_url).await?; - - let url = format!( - "https://www.speedscope.app/#profileURL={}", - encode(&pastila_url) - ); + let pastila_url = + pastila::upload_encrypted(&data, pastila_clickhouse_host, pastila_url).await?; + let url = format!("https://whodidit.you/#profileURL={}", pastila_url); let mut child = open_url_command(&url) .spawn() diff --git a/src/interpreter/worker.rs b/src/interpreter/worker.rs index 1fcb3b1..89b7e87 100644 --- a/src/interpreter/worker.rs +++ b/src/interpreter/worker.rs @@ -316,7 +316,7 @@ async fn render_flamegraph( })) .map_err(|_| anyhow!("Cannot send message to UI"))?; } else { - flamegraph::open_in_speedscope(block, &pastila_clickhouse_host, &pastila_url).await?; + flamegraph::share(block, &pastila_clickhouse_host, &pastila_url).await?; } return Ok(()); } diff --git a/src/pastila.rs b/src/pastila.rs index 5e85492..64041d1 100644 --- a/src/pastila.rs +++ b/src/pastila.rs @@ -172,44 +172,6 @@ async fn get_pastila_client(pastila_clickhouse_host: &str) -> Result Result { - let fingerprint_hex = get_fingerprint(content); - let hash_hex = calculate_hash(content); - - { - let mut client = get_pastila_client(pastila_clickhouse_host).await?; - let block = Block::new() - .column("fingerprint_hex", vec![fingerprint_hex.as_str()]) - .column("hash_hex", vec![hash_hex.as_str()]) - .column("content", vec![content]) - .column("is_encrypted", vec![0_u8]); - client.insert("paste.data", block).await?; - } - - log::info!( - "Uploaded {} bytes to {}", - content.len(), - pastila_clickhouse_host - ); - - let pastila_url = pastila_url.trim_end_matches('/'); - let pastila_page_url = format!("{}/?{}/{}", pastila_url, fingerprint_hex, hash_hex); - log::info!("Pastila URL: {}", pastila_page_url); - - let select_query = format!( - "SELECT content FROM data_view(fingerprint = '{}', hash = '{}') FORMAT TabSeparatedRaw", - fingerprint_hex, hash_hex - ); - let clickhouse_url = format!("{}&query={}", pastila_clickhouse_host, &select_query); - log::info!("Pastila ClickHouse URL: {}", clickhouse_url); - - Ok(clickhouse_url) -} - pub async fn upload_encrypted( content: &str, pastila_clickhouse_host: &str,