package_info: fix check_launchpad_repo needing web requests (use git)
This commit is contained in:
@@ -20,15 +20,15 @@ pub fn ppa_to_base_url(user: &str, name: &str) -> String {
|
|||||||
|
|
||||||
async fn check_launchpad_repo(package: &str) -> Result<Option<String>, Box<dyn Error>> {
|
async fn check_launchpad_repo(package: &str) -> Result<Option<String>, Box<dyn Error>> {
|
||||||
let url = format!("https://git.launchpad.net/ubuntu/+source/{}", package);
|
let url = format!("https://git.launchpad.net/ubuntu/+source/{}", package);
|
||||||
let client = reqwest::Client::builder()
|
|
||||||
.redirect(reqwest::redirect::Policy::none())
|
|
||||||
.build()?;
|
|
||||||
let response = client.head(&url).send().await?;
|
|
||||||
|
|
||||||
if response.status().is_success() {
|
// Use libgit2 to check if the remote repository exists
|
||||||
Ok(Some(url))
|
// This is more reliable than HTTP HEAD requests when CGIt is disabled
|
||||||
} else {
|
match git2::Remote::create_detached(url.clone()) {
|
||||||
Ok(None)
|
Ok(mut remote) => match remote.connect(git2::Direction::Fetch) {
|
||||||
|
Ok(_) => Ok(Some(url)),
|
||||||
|
Err(_) => Ok(None),
|
||||||
|
},
|
||||||
|
Err(_) => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user