Skip to content

Commit c1f23e4

Browse files
committed
Remove flat index client's dependency on registry client
1 parent ed0759f commit c1f23e4

File tree

10 files changed

+24
-18
lines changed

10 files changed

+24
-18
lines changed

crates/uv-client/src/flat_index.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use uv_small_str::SmallString;
1414

1515
use crate::cached_client::{CacheControl, CachedClientError};
1616
use crate::html::SimpleHtml;
17-
use crate::{Connectivity, Error, ErrorKind, OwnedArchive, RegistryClient};
17+
use crate::{CachedClient, Connectivity, Error, ErrorKind, OwnedArchive};
1818

1919
#[derive(Debug, thiserror::Error)]
2020
pub enum FlatIndexError {
@@ -91,14 +91,19 @@ impl FlatIndexEntries {
9191
/// remote HTML indexes).
9292
#[derive(Debug, Clone)]
9393
pub struct FlatIndexClient<'a> {
94-
client: &'a RegistryClient,
94+
client: &'a CachedClient,
95+
connectivity: Connectivity,
9596
cache: &'a Cache,
9697
}
9798

9899
impl<'a> FlatIndexClient<'a> {
99100
/// Create a new [`FlatIndexClient`].
100-
pub fn new(client: &'a RegistryClient, cache: &'a Cache) -> Self {
101-
Self { client, cache }
101+
pub fn new(client: &'a CachedClient, connectivity: Connectivity, cache: &'a Cache) -> Self {
102+
Self {
103+
client,
104+
connectivity,
105+
cache,
106+
}
102107
}
103108

104109
/// Read the directories and flat remote indexes from `--find-links`.
@@ -157,7 +162,7 @@ impl<'a> FlatIndexClient<'a> {
157162
"html",
158163
format!("{}.msgpack", cache_digest(&url.to_string())),
159164
);
160-
let cache_control = match self.client.connectivity() {
165+
let cache_control = match self.connectivity {
161166
Connectivity::Online => CacheControl::from(
162167
self.cache
163168
.freshness(&cache_entry, None, None)
@@ -168,7 +173,8 @@ impl<'a> FlatIndexClient<'a> {
168173

169174
let flat_index_request = self
170175
.client
171-
.uncached_client(url)
176+
.uncached()
177+
.for_host(url)
172178
.get(url.clone())
173179
.header("Accept-Encoding", "gzip")
174180
.header("Accept", "text/html")
@@ -210,7 +216,6 @@ impl<'a> FlatIndexClient<'a> {
210216
};
211217
let response = self
212218
.client
213-
.cached_client()
214219
.get_cacheable_with_retry(
215220
flat_index_request,
216221
&cache_entry,

crates/uv/src/commands/build_frontend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ async fn build_package(
550550

551551
// Resolve the flat indexes from `--find-links`.
552552
let flat_index = {
553-
let client = FlatIndexClient::new(&client, cache);
553+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
554554
let entries = client
555555
.fetch(index_locations.flat_indexes().map(Index::url))
556556
.await?;

crates/uv/src/commands/pip/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ pub(crate) async fn pip_compile(
373373

374374
// Resolve the flat indexes from `--find-links`.
375375
let flat_index = {
376-
let client = FlatIndexClient::new(&client, &cache);
376+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), &cache);
377377
let entries = client
378378
.fetch(index_locations.flat_indexes().map(Index::url))
379379
.await?;

crates/uv/src/commands/pip/install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub(crate) async fn pip_install(
366366

367367
// Resolve the flat indexes from `--find-links`.
368368
let flat_index = {
369-
let client = FlatIndexClient::new(&client, &cache);
369+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), &cache);
370370
let entries = client
371371
.fetch(index_locations.flat_indexes().map(Index::url))
372372
.await?;

crates/uv/src/commands/pip/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub(crate) async fn pip_sync(
294294

295295
// Resolve the flat indexes from `--find-links`.
296296
let flat_index = {
297-
let client = FlatIndexClient::new(&client, &cache);
297+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), &cache);
298298
let entries = client
299299
.fetch(index_locations.flat_indexes().map(Index::url))
300300
.await?;

crates/uv/src/commands/project/add.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ pub(crate) async fn add(
345345

346346
// Resolve the flat indexes from `--find-links`.
347347
let flat_index = {
348-
let client = FlatIndexClient::new(&client, cache);
348+
let client =
349+
FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
349350
let entries = client
350351
.fetch(
351352
settings

crates/uv/src/commands/project/lock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ async fn do_lock(
634634

635635
// Resolve the flat indexes from `--find-links`.
636636
let flat_index = {
637-
let client = FlatIndexClient::new(&client, cache);
637+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
638638
let entries = client
639639
.fetch(index_locations.flat_indexes().map(Index::url))
640640
.await?;

crates/uv/src/commands/project/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ pub(crate) async fn resolve_environment(
17521752

17531753
// Resolve the flat indexes from `--find-links`.
17541754
let flat_index = {
1755-
let client = FlatIndexClient::new(&client, cache);
1755+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
17561756
let entries = client
17571757
.fetch(index_locations.flat_indexes().map(Index::url))
17581758
.await?;
@@ -1895,7 +1895,7 @@ pub(crate) async fn sync_environment(
18951895

18961896
// Resolve the flat indexes from `--find-links`.
18971897
let flat_index = {
1898-
let client = FlatIndexClient::new(&client, cache);
1898+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
18991899
let entries = client
19001900
.fetch(index_locations.flat_indexes().map(Index::url))
19011901
.await?;
@@ -2122,7 +2122,7 @@ pub(crate) async fn update_environment(
21222122

21232123
// Resolve the flat indexes from `--find-links`.
21242124
let flat_index = {
2125-
let client = FlatIndexClient::new(&client, cache);
2125+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
21262126
let entries = client
21272127
.fetch(index_locations.flat_indexes().map(Index::url))
21282128
.await?;

crates/uv/src/commands/project/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ pub(super) async fn do_sync(
654654

655655
// Resolve the flat indexes from `--find-links`.
656656
let flat_index = {
657-
let client = FlatIndexClient::new(&client, cache);
657+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
658658
let entries = client
659659
.fetch(index_locations.flat_indexes().map(Index::url))
660660
.await?;

crates/uv/src/commands/venv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ async fn venv_impl(
306306
// Resolve the flat indexes from `--find-links`.
307307
let flat_index = {
308308
let tags = interpreter.tags().map_err(VenvError::Tags)?;
309-
let client = FlatIndexClient::new(&client, cache);
309+
let client = FlatIndexClient::new(client.cached_client(), client.connectivity(), cache);
310310
let entries = client
311311
.fetch(index_locations.flat_indexes().map(Index::url))
312312
.await

0 commit comments

Comments
 (0)