Skip to content

Commit

Permalink
Use assertions for cleaner checks
Browse files Browse the repository at this point in the history
  • Loading branch information
harshdoesdev committed Oct 6, 2023
1 parent dee5f1e commit 045fc2b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/commands/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ pub async fn download(

let output_get_res = output_get_req.get().await?;

assert!(output_get_res.status().is_success(), "Build artifacts could not be downloaded.");

println!("Build artifacts downloaded");

let buf = &output_get_res.bytes().await?.to_vec();

if !vercel_cache_helper::utils::is_zstd_compressed(&buf) {
return Err(vercel_cache_helper::Error::InvalidInput(
format!(
"Downloaded archive (Size: {}) is not zstd compressed",
&buf.len()
)
));
}
assert!(vercel_cache_helper::utils::is_zstd_compressed(&buf), "Downloaded archive (Size: {}) is not zstd compressed.", &buf.len());

output_dir_archive.write_all(buf)?;

Expand Down
4 changes: 3 additions & 1 deletion src/commands/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ pub async fn upload(

pb.set_message("Uploading artfiacts...");

output_put_req
let res = output_put_req
.buffer(&mut output_archive_buf, output_archive_size)
.await?;

assert!(res.status().is_success(), "Could not upload artifacts.");

pb.finish_with_message("Artifacts uploaded successfully.");

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/vercel/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl RequestHeaders for ArtifactBaseRequest {
if method == "PUT" {
headers.insert(
reqwest::header::CONTENT_TYPE,
reqwest::header::HeaderValue::from_static("application/octet-stream"),
reqwest::header::HeaderValue::from_static("application/zstd"),
);

if let Some(content_len) = content_len {
Expand Down

0 comments on commit 045fc2b

Please sign in to comment.