diff --git a/crates/ptth_server/src/file_server.rs b/crates/ptth_server/src/file_server.rs index e9d42e2..6b98539 100644 --- a/crates/ptth_server/src/file_server.rs +++ b/crates/ptth_server/src/file_server.rs @@ -312,12 +312,12 @@ async fn stream_file ( break; } - buffer.truncate (bytes_read); - let bytes_read_64 = u64::try_from (bytes_read).expect ("Couldn't fit usize into u64"); let bytes_read_64 = min (bytes_left, bytes_read_64); + buffer.truncate (bytes_read_64 as usize); + if tx.send (Ok::<_, Infallible> (buffer)).await.is_err () { warn! ("Cancelling file stream (Sent {} out of {} bytes)", bytes_sent, content_length); break;