-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
33 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
crates/rattler_installs_packages/src/index/direct_url/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
use crate::index::http::Http; | ||
use crate::index::package_database::DirectUrlArtifactResponse; | ||
use crate::types::NormalizedPackageName; | ||
use crate::wheel_builder::WheelBuilder; | ||
use url::Url; | ||
|
||
pub(crate) mod file; | ||
pub(crate) mod git; | ||
pub(crate) mod http; | ||
|
||
/// Get artifact directly from file, vcs, or url | ||
pub(crate) async fn fetch_artifact_and_metadata_by_direct_url<P: Into<NormalizedPackageName>>( | ||
http: &Http, | ||
p: P, | ||
url: Url, | ||
wheel_builder: &WheelBuilder, | ||
) -> miette::Result<DirectUrlArtifactResponse> { | ||
let p = p.into(); | ||
|
||
let response = if url.scheme() == "file" { | ||
// This can result in a Wheel, Sdist or STree | ||
super::direct_url::file::get_artifacts_and_metadata(p.clone(), url, wheel_builder).await | ||
} else if url.scheme() == "https" { | ||
// This can be a Wheel or SDist artifact | ||
super::direct_url::http::get_artifacts_and_metadata(http, p.clone(), url, wheel_builder) | ||
.await | ||
} else if url.scheme() == "git+https" || url.scheme() == "git+file" { | ||
// This can be a STree artifact | ||
super::direct_url::git::get_artifacts_and_metadata(p.clone(), url, wheel_builder).await | ||
} else { | ||
Err(miette::miette!( | ||
"Usage of insecure protocol or unsupported scheme {:?}", | ||
url.scheme() | ||
)) | ||
}?; | ||
|
||
Ok(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters