Skip existing, second iteration: Check the index before uploading (#8531)

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
konsti 2024-10-31 16:23:12 +01:00 committed by GitHub
parent b52f229862
commit 082259493e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 487 additions and 223 deletions

View file

@ -31,7 +31,7 @@ use crate::cached_client::CacheControl;
use crate::html::SimpleHtml;
use crate::remote_metadata::wheel_metadata_from_remote_zip;
use crate::rkyvutil::OwnedArchive;
use crate::{CachedClient, CachedClientError, Error, ErrorKind};
use crate::{BaseClient, CachedClient, CachedClientError, Error, ErrorKind};
/// A builder for an [`RegistryClient`].
#[derive(Debug, Clone)]
@ -143,6 +143,27 @@ impl<'a> RegistryClientBuilder<'a> {
timeout,
}
}
/// Share the underlying client between two different middleware configurations.
pub fn wrap_existing(self, existing: &BaseClient) -> RegistryClient {
// Wrap in any relevant middleware and handle connectivity.
let client = self.base_client_builder.wrap_existing(existing);
let timeout = client.timeout();
let connectivity = client.connectivity();
// Wrap in the cache middleware.
let client = CachedClient::new(client);
RegistryClient {
index_urls: self.index_urls,
index_strategy: self.index_strategy,
cache: self.cache,
connectivity,
client,
timeout,
}
}
}
impl<'a> TryFrom<BaseClientBuilder<'a>> for RegistryClientBuilder<'a> {