Return Url in GhApiClient::has_release_artifact

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-06-03 22:29:31 +10:00
parent eb77ad762b
commit 4da2f0e64f
No known key found for this signature in database
GPG key ID: 76D1E687CA3C4928
2 changed files with 5 additions and 3 deletions

View file

@ -12,6 +12,7 @@ use std::{
use binstalk_downloader::remote;
use compact_str::{format_compact, CompactString};
use tokio::sync::OnceCell;
use url::Url;
mod common;
mod error;
@ -210,7 +211,7 @@ impl GhApiClient {
release,
artifact_name,
}: GhReleaseArtifact,
) -> Result<Option<CompactString>, GhApiError> {
) -> Result<Option<Url>, GhApiError> {
let once_cell = self.0.release_artifacts.get(release.clone());
let res = once_cell
.get_or_try_init(|| {

View file

@ -9,6 +9,7 @@ use std::{
use binstalk_downloader::remote::{self};
use compact_str::{CompactString, ToCompactString};
use serde::Deserialize;
use url::Url;
use super::{
common::{issue_graphql_query, issue_restful_api},
@ -20,7 +21,7 @@ use super::{
#[derive(Eq, Deserialize, Debug)]
struct Artifact {
name: CompactString,
url: CompactString,
url: Url,
}
// Manually implement PartialEq and Hash to ensure it will always produce the
@ -59,7 +60,7 @@ pub(super) struct Artifacts {
impl Artifacts {
/// get url for downloading the artifact using GitHub API (for private repository).
pub(super) fn get_artifact_url(&self, artifact_name: &str) -> Option<CompactString> {
pub(super) fn get_artifact_url(&self, artifact_name: &str) -> Option<Url> {
self.assets
.get(artifact_name)
.map(|artifact| artifact.url.clone())