Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ async fn main() -> Result<()> {
Vec::new()
};

// Parse owner/repo for API URL construction
let parts: Vec<&str> = repo.split('/').collect();
if parts.len() != 2 {
return Err(GhrError::Generic(format!(
"Invalid repository format '{}'. Expected 'owner/repo'",
repo
)));
}
let owner = parts[0];
let repo_name = parts[1];

// Collect assets to download with filtering
let mut assets_to_download = Vec::new();
for asset in &release.assets {
Expand All @@ -343,8 +354,12 @@ async fn main() -> Result<()> {
continue;
}

// Get download URL
let download_url = &asset.browser_download_url;
// Use API URL for downloading (works with private repos)
// Format: https://api.github.com/repos/{owner}/{repo}/releases/assets/{asset_id}
let download_url = format!(
"{}/repos/{}/{}/releases/assets/{}",
cli.api_url, owner, repo_name, asset.id
);

// Get asset size for progress bar
let size = asset.size;
Expand All @@ -356,7 +371,7 @@ async fn main() -> Result<()> {
PathBuf::from(name)
};

assets_to_download.push((name.clone(), download_url.clone(), output_path, size));
assets_to_download.push((name.clone(), download_url, output_path, size));
}

if assets_to_download.is_empty() {
Expand Down
1 change: 1 addition & 0 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fmt::Display;
/// GitHub release asset
#[derive(Debug, Deserialize, Serialize)]
pub struct Asset {
pub id: u64,
pub name: String,
pub browser_download_url: String,
pub size: u64,
Expand Down
Loading