From 52d487a8d3611ad7096b2a286cbc71316f70986c Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 14 Mar 2025 13:21:03 +0100 Subject: [PATCH] . --- crates/uv-python/src/downloads.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/uv-python/src/downloads.rs b/crates/uv-python/src/downloads.rs index 48ac87a81..39d3b3f90 100644 --- a/crates/uv-python/src/downloads.rs +++ b/crates/uv-python/src/downloads.rs @@ -6,13 +6,14 @@ use std::task::{Context, Poll}; use std::time::{Duration, SystemTime}; use std::{env, io}; -use futures::TryStreamExt; +use futures::{StreamExt, TryStreamExt}; use owo_colors::OwoColorize; use reqwest_retry::RetryPolicy; use thiserror::Error; use tokio::io::{AsyncRead, AsyncWriteExt, BufWriter, ReadBuf}; use tokio_util::compat::FuturesAsyncReadCompatExt; use tokio_util::either::Either; +use tokio_util::io::{ReaderStream, StreamReader}; use tracing::{debug, instrument}; use url::Url; @@ -688,7 +689,7 @@ impl ManagedPythonDownload { target_cache_file.simplified_display() ); - let (mut reader, size) = read_url(url, client).await?; + let (reader, size) = read_url(url, client).await?; let temp_dir = tempfile::tempdir_in(python_builds_dir)?; let temp_file = temp_dir.path().join("download"); @@ -703,6 +704,17 @@ impl ManagedPythonDownload { ) }); + let mut other_writer = fs_err::tokio::File::create("other.bin").await?; + let other_writer_ref = &mut other_writer; + + let mut reader = Box::pin(StreamReader::new(ReaderStream::new(reader).then( + |bytes| async { + let bytes = bytes?; + other_writer_ref.write_all(&bytes).await?; + Ok::<_, io::Error>(bytes) + }, + ))); + match progress { Some((&reporter, progress)) => { tokio::io::copy(