🐛 bug: fix content length when byte serving

main
_ 2021-11-13 21:31:30 -06:00
parent 80f1c21fd0
commit b642142332
1 changed files with 2 additions and 2 deletions

View File

@ -312,12 +312,12 @@ async fn stream_file (
break; 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 = u64::try_from (bytes_read).expect ("Couldn't fit usize into u64");
let bytes_read_64 = min (bytes_left, bytes_read_64); 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 () { if tx.send (Ok::<_, Infallible> (buffer)).await.is_err () {
warn! ("Cancelling file stream (Sent {} out of {} bytes)", bytes_sent, content_length); warn! ("Cancelling file stream (Sent {} out of {} bytes)", bytes_sent, content_length);
break; break;