Release 1.6180339887

- drop the rust version from the Cargo.toml
 - info-log the upload transfer rate
This commit is contained in:
Joe Ardent 2026-08-02 12:25:10 -07:00
parent 598c9109f8
commit fff8235bc5
4 changed files with 35 additions and 10 deletions

2
Cargo.lock generated
View file

@ -1344,7 +1344,7 @@ dependencies = [
[[package]] [[package]]
name = "jocalsend" name = "jocalsend"
version = "1.6.18033988" version = "1.6.180339887"
dependencies = [ dependencies = [
"axum", "axum",
"axum-server", "axum-server",

View file

@ -1,10 +1,9 @@
[package] [package]
name = "jocalsend" name = "jocalsend"
# 1.61803398874989484 # 1.61803398874989484
#-----------^ #------------^
version = "1.6.18033988" version = "1.6.180339887"
edition = "2024" edition = "2024"
rust-version = "1.89"
authors = ["Joe Ardent <code@ardent.nebcorp.com>"] authors = ["Joe Ardent <code@ardent.nebcorp.com>"]
keywords = ["p2p", "localsend", "tui", "linux"] keywords = ["p2p", "localsend", "tui", "linux"]
description = "A TUI for LocalSend" description = "A TUI for LocalSend"

View file

@ -1 +1 @@
1.618033988 1.6180339887

View file

@ -1,4 +1,9 @@
use std::{collections::BTreeMap, net::SocketAddr, path::PathBuf, time::Duration}; use std::{
collections::BTreeMap,
net::SocketAddr,
path::PathBuf,
time::{Duration, Instant},
};
use axum::{ use axum::{
Json, Json,
@ -152,10 +157,11 @@ impl JocalService {
.map(|(_, peer)| peer.alias.as_str()) .map(|(_, peer)| peer.alias.as_str())
.unwrap_or("unknown peer") .unwrap_or("unknown peer")
); );
let num_bytes = bytes.len();
let resp = do_send_bytes(sessions, client, &session_id, content_id, token, bytes).await; let resp = do_send_bytes(sessions, client, &session_id, content_id, token, bytes).await;
match resp { match resp {
Ok(_) => { Ok(dur) => {
send_tx( send_tx(
JocalEvent::SendSuccess { JocalEvent::SendSuccess {
content: content_id.to_owned(), content: content_id.to_owned(),
@ -163,6 +169,11 @@ impl JocalService {
}, },
&tx, &tx,
); );
log::info!(
"transferred {num_bytes} bytes in {} seconds ({})",
dur.as_secs_f32(),
format_bytes_per_second(num_bytes as f32 / dur.as_secs_f32())
);
} }
Err(e) => { Err(e) => {
send_tx( send_tx(
@ -307,6 +318,8 @@ pub async fn handle_receive_upload(
// Create file path // Create file path
let file_path = service.config.download_dir.join(&file_metadata.file_name); let file_path = service.config.download_dir.join(&file_metadata.file_name);
let num_bytes = body.len();
// Write file // Write file
if let Err(e) = tokio::fs::write(&file_path, body).await { if let Err(e) = tokio::fs::write(&file_path, body).await {
log::warn!("could not save content to {file_path:?}, got {e}"); log::warn!("could not save content to {file_path:?}, got {e}");
@ -314,7 +327,7 @@ pub async fn handle_receive_upload(
} }
log::info!( log::info!(
"saved content from {} to {file_path:?}", "wrote {num_bytes} from {} to {file_path:?}",
session.sender.alias session.sender.alias
); );
if let Ok(id) = Julid::from_str(session_id) { if let Ok(id) = Julid::from_str(session_id) {
@ -371,7 +384,7 @@ async fn do_send_bytes(
content_id: &str, content_id: &str,
token: &str, token: &str,
body: Bytes, body: Bytes,
) -> Result<()> { ) -> Result<Duration> {
let session = sessions let session = sessions
.read() .read()
.await .await
@ -394,13 +407,15 @@ async fn do_send_bytes(
.body(body); .body(body);
debug!("Uploading bytes: {request:?}"); debug!("Uploading bytes: {request:?}");
let now = Instant::now();
let response = request.send().await?; let response = request.send().await?;
let dur = Instant::now() - now;
if response.status() != 200 { if response.status() != 200 {
log::warn!("non-200 remote response: {response:?}"); log::warn!("non-200 remote response: {response:?}");
Err(LocalSendError::UploadFailed) Err(LocalSendError::UploadFailed)
} else { } else {
Ok(()) Ok(dur)
} }
} }
@ -464,3 +479,14 @@ async fn do_prepare_upload(
Ok(response) Ok(response)
} }
fn format_bytes_per_second(bps: f32) -> String {
if bps >= 1024.0f32.powi(2) {
return format!("{} MB/s", bps / 1024.0f32.powi(2));
}
if bps >= 1024.0 {
return format!("{} KB/s", bps / 1024.0);
}
format!("{bps} B/s")
}