Skip to content

Commit

Permalink
Fix downloads using new github endpoint, more error reporting improve…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
filiptibell committed Mar 27, 2024
1 parent 6d13a53 commit 3cdb95f
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 32 deletions.
136 changes: 134 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ async-signal = "0.2"
futures = "0.3"
http = "1.1"
http-body-util = "0.1"
reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls",
"http2",
] }
tokio = { version = "1.36", features = ["full"] }
tracing = "0.1"

Expand Down
10 changes: 4 additions & 6 deletions lib/sources/artifact.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fmt, str::FromStr};

use octocrab::models::repos::Asset;
use tracing::{debug, instrument};
use tracing::instrument;
use url::Url;

use crate::{
Expand Down Expand Up @@ -124,8 +124,6 @@ impl Artifact {
*/
#[instrument(skip(self, contents), level = "debug")]
pub async fn extract_contents(&self, contents: Vec<u8>) -> RokitResult<Vec<u8>> {
debug!("Extracting artifact contents");

let format = self.format.ok_or(RokitError::ExtractUnknownFormat)?;

let file_name = self.tool_spec.name().to_string();
Expand All @@ -136,9 +134,9 @@ impl Artifact {
let file_opt = file_res.map_err(|err| RokitError::ExtractError {
source: err.into(),
body: {
if contents.len() > 86 {
let bytes = contents.iter().cloned().take(80).collect::<Vec<_>>();
format!("{} <...>", String::from_utf8_lossy(bytes.as_slice()))
if contents.len() > 128 + 6 {
let bytes = contents.iter().cloned().take(128).collect::<Vec<_>>();
format!("{} <...>", String::from_utf8_lossy(bytes.as_slice()).trim())
} else {
String::from_utf8_lossy(&contents).to_string()
}
Expand Down
2 changes: 0 additions & 2 deletions lib/sources/extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pub async fn extract_zip_file(

let zip_contents = zip_contents.as_ref().to_vec();
let num_bytes = zip_contents.len();

tracing::debug!(num_bytes, "Extracting zip file");
let start = Instant::now();

// Reading a zip file is a potentially expensive operation, so
Expand Down
Loading

0 comments on commit 3cdb95f

Please sign in to comment.