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
2 changes: 1 addition & 1 deletion src/commands/dart_symbol_map/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub(super) fn execute(args: DartSymbolMapUploadArgs) -> Result<()> {
let options = ChunkOptions::new(chunk_upload_options, org, project)
.with_max_wait(DEFAULT_MAX_WAIT);

let chunked = Chunked::from(object, options.server_options().chunk_size as usize)?;
let chunked = Chunked::from(object, (options.server_options().chunk_size as usize).try_into()?);
let (_uploaded, has_processing_errors) = upload_chunked_objects(&[chunked], options)?;
if has_processing_errors {
bail!("Some symbol maps did not process correctly");
Expand Down
14 changes: 7 additions & 7 deletions src/utils/chunks/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use std::borrow::Cow;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::num::NonZeroUsize;

use anyhow::Result;
use sha1_smol::Digest;
use symbolic::common::DebugId;

Expand Down Expand Up @@ -37,7 +37,7 @@ pub struct Chunked<T> {
chunks: Vec<Digest>,

/// Size of a single chunk
chunk_size: usize,
chunk_size: NonZeroUsize,
}

impl<T> Chunked<T> {
Expand All @@ -63,14 +63,14 @@ where
{
/// Creates a new `ChunkedObject` from the given object, using
/// the given chunk size.
pub fn from(object: T, chunk_size: usize) -> Result<Self> {
let (checksum, chunks) = fs::get_sha1_checksums(object.as_ref(), chunk_size.try_into()?);
Ok(Self {
pub fn from(object: T, chunk_size: NonZeroUsize) -> Self {
let (checksum, chunks) = fs::get_sha1_checksums(object.as_ref(), chunk_size);
Self {
object,
checksum,
chunks,
chunk_size,
})
}
}

/// Returns an iterator over all chunks of the object.
Expand All @@ -79,7 +79,7 @@ where
pub fn iter_chunks(&self) -> impl Iterator<Item = Chunk<'_>> {
self.object
.as_ref()
.chunks(self.chunk_size)
.chunks(self.chunk_size.into())
.zip(self.chunk_hashes().iter())
.map(|(data, checksum)| Chunk((*checksum, data)))
}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/dif_upload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,10 @@ fn upload_difs_chunked(
processed.extend(source_bundles);
}

let chunk_size = (chunk_options.chunk_size as usize).try_into()?;

// Calculate checksums and chunks
let chunked = prepare_difs(processed, |m| {
Chunked::from(m, chunk_options.chunk_size as usize)
})?;
let chunked = prepare_difs(processed, |m| Ok(Chunked::from(m, chunk_size)))?;

if options.no_upload {
println!("{} skipping upload.", style(">").dim());
Expand Down
5 changes: 3 additions & 2 deletions src/utils/proguard/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ pub fn chunk_upload(
org: &str,
project: &str,
) -> Result<()> {
let chunk_size = (chunk_upload_options.chunk_size as usize).try_into()?;
let chunked_mappings = mappings
.iter()
.map(|mapping| Chunked::from(mapping, chunk_upload_options.chunk_size as usize))
.collect::<Result<Vec<_>>>()?;
.map(|mapping| Chunked::from(mapping, chunk_size))
.collect::<Vec<_>>();

let options =
ChunkOptions::new(chunk_upload_options, org, project).with_max_wait(ASSEMBLE_POLL_TIMEOUT);
Expand Down
Loading