Skip to content

Commit

Permalink
fix: crate build issues with stream feature (#711)
Browse files Browse the repository at this point in the history
* fix: crate build issues with `stream` feature

Fix a build issue introduced by #690 when building octocrab with the
`stream` feature.

Closes: #707

* style: cargo fmt

* ci: add checks for `stream` feature

* docs: fix release-asset stream test

* Add LLVM for symboliser.

* Add ubuntu check

* Remove --verbose

* ci: feature matrix

* ci: add missing dollar sign

---------

Co-authored-by: XAMPPRocky <4464295+XAMPPRocky@users.noreply.github.com>
  • Loading branch information
benpueschel and XAMPPRocky authored Oct 15, 2024
1 parent 9647ad4 commit 227716f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ jobs:
matrix:
channel: [stable, beta, nightly]
os: [ubuntu, macos, windows]
features:
- ""
- "-F stream"
steps:
- uses: actions/checkout@v2
- run: rustup default ${{ matrix.channel }}
- run: cargo build --all-targets
- run: cargo test
- run: cargo build --all-targets ${{ matrix.features }}
- run: cargo test ${{ matrix.features }}

wasm-build:
runs-on: ubuntu-latest
Expand Down
15 changes: 5 additions & 10 deletions src/api/repos/release_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'octo, 'r> ReleaseAssetsHandler<'octo, 'r> {
/// let mut stream = octocrab::instance()
/// .repos("owner", "repo")
/// .release_assets()
/// .stream_asset(AssetId(42u64))
/// .stream(42u64)
/// .await?;
///
/// while let Some(chunk) = stream.next().await {
Expand All @@ -92,12 +92,7 @@ impl<'octo, 'r> ReleaseAssetsHandler<'octo, 'r> {
use futures_util::TryStreamExt;
//use snafu::GenerateImplicitData;

let route = format!(
"/{}/releases/assets/{id}",
owner = self.parent.owner,
repo = self.parent.repo,
id = id,
);
let route = format!("/{}/releases/assets/{id}", self.handler.repo, id = id,);

let uri = Uri::builder()
.path_and_query(route)
Expand All @@ -107,9 +102,9 @@ impl<'octo, 'r> ReleaseAssetsHandler<'octo, 'r> {
.method(http::Method::GET)
.uri(uri)
.header(http::header::ACCEPT, "application/octet-stream");
let request = self.parent.crab.build_request(builder, None::<&()>)?;
let response = self.parent.crab.execute(request).await?;
let response = self.parent.crab.follow_location_to_data(response).await?;
let request = self.handler.crab.build_request(builder, None::<&()>)?;
let response = self.handler.crab.execute(request).await?;
let response = self.handler.crab.follow_location_to_data(response).await?;
Ok(http_body_util::BodyStream::new(response.into_body())
.try_filter_map(|frame| futures_util::future::ok(frame.into_data().ok())))
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/repos/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<'octo, 'r> ReleasesHandler<'octo, 'r> {
&self,
asset_id: u64,
) -> crate::Result<impl futures_core::Stream<Item = crate::Result<bytes::Bytes>>> {
self.parent.release_assets().stream(asset_id).await
self.handler.release_assets().stream(asset_id).await
}

/// Delete a release using its id.
Expand Down

0 comments on commit 227716f

Please sign in to comment.