Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions crates/uv-python/src/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,14 @@ impl ManagedPythonDownload {
client: &uv_client::BaseClient,
installation_dir: &Path,
cache_dir: &Path,
reinstall: bool,
reporter: Option<&dyn Reporter>,
) -> Result<DownloadResult, Error> {
let url = self.download_url()?;
let path = installation_dir.join(self.key().to_string());

// If it already exists, return it
if path.is_dir() {
// If it is not a reinstall and the dir already exists, return it.
if !reinstall && path.is_dir() {
return Ok(DownloadResult::AlreadyAvailable(path));
}

Expand Down Expand Up @@ -560,7 +561,13 @@ impl ManagedPythonDownload {
}
}

// Persist it to the target
// Remove the target if it already exists.
if path.is_dir() {
debug!("Removing existing directory: {}", path.user_display());
fs_err::tokio::remove_dir_all(&path).await?;
}

// Persist it to the target.
debug!("Moving {} to {}", extracted.display(), path.user_display());
rename_with_retry(extracted, &path)
.await
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-python/src/installation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl PythonInstallation {

info!("Fetching requested Python...");
let result = download
.fetch(&client, installations_dir, &cache_dir, reporter)
.fetch(&client, installations_dir, &cache_dir, false, reporter)
.await?;

let path = match result {
Expand Down
10 changes: 7 additions & 3 deletions crates/uv/src/commands/python/install.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Result;
use fs_err as fs;
use futures::stream::FuturesUnordered;
use futures::StreamExt;
use itertools::Itertools;
Expand Down Expand Up @@ -90,7 +89,6 @@ pub(crate) async fn install(
)?;
}
if reinstall {
fs::remove_dir_all(installation.path())?;
uninstalled.push(installation.key().clone());
unfilled_requests.push(download_request);
}
Expand Down Expand Up @@ -145,7 +143,13 @@ pub(crate) async fn install(
(
download.key(),
download
.fetch(&client, installations_dir, &cache_dir, Some(&reporter))
.fetch(
&client,
installations_dir,
&cache_dir,
reinstall,
Some(&reporter),
)
.await,
)
});
Expand Down
Loading