Skip to content

Commit

Permalink
add fetch repo data to py-rattler (#334)
Browse files Browse the repository at this point in the history
This adds `fetch_repo_data` to py-rattler.

Co-authored-by: Bas Zalmstra <[email protected]>
  • Loading branch information
Wackyator and baszalmstra authored Sep 26, 2023
1 parent 8b82537 commit c6f1e3f
Show file tree
Hide file tree
Showing 42 changed files with 2,022 additions and 158 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: true
- run: |
curl -fsSL https://pixi.sh/install.sh | bash
echo "/home/runner/.pixi/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler-bin/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ async fn fetch_repo_data_records_with_progress(
let result = rattler_repodata_gateway::fetch::fetch_repo_data(
channel.platform_url(platform),
client,
repodata_cache,
repodata_cache.to_path_buf(),
FetchRepoDataOptions::default(),
Some(Box::new(move |DownloadProgress { total, bytes }| {
download_progress_progress_bar.set_length(total.unwrap_or(bytes));
Expand Down
28 changes: 14 additions & 14 deletions crates/rattler_repodata_gateway/src/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async fn repodata_from_file(
pub async fn fetch_repo_data(
subdir_url: Url,
client: AuthenticatedClient,
cache_path: &Path,
cache_path: PathBuf,
options: FetchRepoDataOptions,
progress: Option<ProgressFunc>,
) -> Result<CachedRepoData, FetchRepoDataError> {
Expand Down Expand Up @@ -321,7 +321,7 @@ pub async fn fetch_repo_data(
// Validate the current state of the cache
let cache_state = if cache_action != CacheAction::NoCache {
let owned_subdir_url = subdir_url.clone();
let owned_cache_path = cache_path.to_owned();
let owned_cache_path = cache_path.clone();
let owned_cache_key = cache_key.clone();
let cache_state = tokio::task::spawn_blocking(move || {
validate_cached_state(&owned_cache_path, &owned_subdir_url, &owned_cache_key)
Expand Down Expand Up @@ -530,7 +530,7 @@ pub async fn fetch_repo_data(
} else {
Encoding::Passthrough
},
cache_path,
&cache_path,
progress,
)
.await?;
Expand Down Expand Up @@ -1114,7 +1114,7 @@ mod test {
let result = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
Default::default(),
None,
)
Expand Down Expand Up @@ -1144,7 +1144,7 @@ mod test {
let CachedRepoData { cache_result, .. } = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.path().to_owned(),
Default::default(),
None,
)
Expand All @@ -1157,7 +1157,7 @@ mod test {
let CachedRepoData { cache_result, .. } = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.path().to_owned(),
Default::default(),
None,
)
Expand All @@ -1181,7 +1181,7 @@ mod test {
let CachedRepoData { cache_result, .. } = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
Default::default(),
None,
)
Expand Down Expand Up @@ -1210,7 +1210,7 @@ mod test {
let result = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
Default::default(),
None,
)
Expand Down Expand Up @@ -1252,7 +1252,7 @@ mod test {
let result = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
Default::default(),
None,
)
Expand Down Expand Up @@ -1301,7 +1301,7 @@ mod test {
let result = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
Default::default(),
None,
)
Expand Down Expand Up @@ -1354,7 +1354,7 @@ mod test {
let result = fetch_repo_data(
server.url(),
authenticated_client,
cache_dir.path(),
cache_dir.into_path(),
Default::default(),
None,
)
Expand Down Expand Up @@ -1387,7 +1387,7 @@ mod test {
let _result = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
FetchRepoDataOptions {
..Default::default()
},
Expand All @@ -1412,7 +1412,7 @@ mod test {
Url::parse(format!("file://{}", subdir_path.path().to_str().unwrap()).as_str())
.unwrap(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
FetchRepoDataOptions {
..Default::default()
},
Expand All @@ -1436,7 +1436,7 @@ mod test {
let result = fetch_repo_data(
server.url(),
AuthenticatedClient::default(),
cache_dir.path(),
cache_dir.into_path(),
FetchRepoDataOptions {
..Default::default()
},
Expand Down
4 changes: 2 additions & 2 deletions crates/rattler_repodata_gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//! using the [`fetch::fetch_repo_data`] function:
//!
//! ```no_run
//! use std::{path::Path, default::Default};
//! use std::{path::PathBuf, default::Default};
//! use rattler_networking::AuthenticatedClient;
//! use url::Url;
//! use rattler_repodata_gateway::fetch;
Expand All @@ -35,7 +35,7 @@
//! async fn main() {
//! let repodata_url = Url::parse("https://conda.anaconda.org/conda-forge/osx-64/").unwrap();
//! let client = AuthenticatedClient::default();
//! let cache = Path::new("./cache");
//! let cache = PathBuf::from("./cache");
//!
//! let result = fetch::fetch_repo_data(
//! repodata_url,
Expand Down
Loading

0 comments on commit c6f1e3f

Please sign in to comment.