diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-01-01 23:26:00 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-01-01 23:46:06 +0100 |
commit | d022f4f1bd267167e587d4c21a8298151f99ea1e (patch) | |
tree | b22b193c7a547c543c4af209fddb2dff3a91d3ef /src/repository.rs | |
parent | Merge pull request 'add authentication options' (#32) from auth into main (diff) | |
download | forgejo-api-d022f4f1bd267167e587d4c21a8298151f99ea1e.tar.xz forgejo-api-d022f4f1bd267167e587d4c21a8298151f99ea1e.zip |
fix archive download methods
Diffstat (limited to '')
-rw-r--r-- | src/repository.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/repository.rs b/src/repository.rs index d9a92b1..22c518b 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -207,35 +207,23 @@ impl Forgejo { .await } - pub async fn download_release_zip( + pub async fn download_zip_archive( &self, owner: &str, repo: &str, - release: u64, + target: &str, ) -> Result<Option<bytes::Bytes>, ForgejoError> { - let release = self.get_release(owner, repo, release).await; - let release = match release { - Ok(Some(release)) => release, - Ok(None) => return Ok(None), - Err(e) => return Err(e), - }; - let request = self.client.get(release.zipball_url).build()?; + let request = self.client.get(format!("repos/{owner}/{repo}/archive/{target}.zip")).build()?; self.execute_opt_raw(request).await } - pub async fn download_release_tarball( + pub async fn download_tarball_archive( &self, owner: &str, repo: &str, - release: u64, + target: &str, ) -> Result<Option<bytes::Bytes>, ForgejoError> { - let release = self.get_release(owner, repo, release).await; - let release = match release { - Ok(Some(release)) => release, - Ok(None) => return Ok(None), - Err(e) => return Err(e), - }; - let request = self.client.get(release.tarball_url).build()?; + let request = self.client.get(format!("repos/{owner}/{repo}/archive/{target}.tar.gz")).build()?; self.execute_opt_raw(request).await } |