diff --git a/src/commands/dart_symbol_map/upload.rs b/src/commands/dart_symbol_map/upload.rs index 9786446e0f..4c8ab4089c 100644 --- a/src/commands/dart_symbol_map/upload.rs +++ b/src/commands/dart_symbol_map/upload.rs @@ -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"); diff --git a/src/utils/chunks/types.rs b/src/utils/chunks/types.rs index 2d342d177a..a8a1ceca2d 100644 --- a/src/utils/chunks/types.rs +++ b/src/utils/chunks/types.rs @@ -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; @@ -37,7 +37,7 @@ pub struct Chunked { chunks: Vec, /// Size of a single chunk - chunk_size: usize, + chunk_size: NonZeroUsize, } impl Chunked { @@ -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 { - 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. @@ -79,7 +79,7 @@ where pub fn iter_chunks(&self) -> impl Iterator> { self.object .as_ref() - .chunks(self.chunk_size) + .chunks(self.chunk_size.into()) .zip(self.chunk_hashes().iter()) .map(|(data, checksum)| Chunk((*checksum, data))) } diff --git a/src/utils/dif_upload/mod.rs b/src/utils/dif_upload/mod.rs index 1e28c2e016..7d851f3337 100644 --- a/src/utils/dif_upload/mod.rs +++ b/src/utils/dif_upload/mod.rs @@ -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()); diff --git a/src/utils/proguard/upload.rs b/src/utils/proguard/upload.rs index 94a20a254f..2d251795fc 100644 --- a/src/utils/proguard/upload.rs +++ b/src/utils/proguard/upload.rs @@ -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::>>()?; + .map(|mapping| Chunked::from(mapping, chunk_size)) + .collect::>(); let options = ChunkOptions::new(chunk_upload_options, org, project).with_max_wait(ASSEMBLE_POLL_TIMEOUT);