Skip to content

Commit edabdef

Browse files
ref(api): Rename ChunkedUploadOptions to indicate they are set by server
This rename makes it clearer that the server sets the `ChunkedServerOptions`. It also will allow `ChunkedUploadOptions` to be used to store options that are user-configured
1 parent 87444d5 commit edabdef

File tree

8 files changed

+19
-18
lines changed

8 files changed

+19
-18
lines changed

src/api/data_types/chunking/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ pub use self::compression::ChunkCompression;
1313
pub use self::dif::{AssembleDifsRequest, AssembleDifsResponse, ChunkedDifRequest};
1414
pub use self::file_state::ChunkedFileState;
1515
pub use self::hash_algorithm::ChunkHashAlgorithm;
16-
pub use self::upload::{ChunkUploadCapability, ChunkUploadOptions};
16+
pub use self::upload::{ChunkServerOptions, ChunkUploadCapability};

src/api/data_types/chunking/upload/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ mod capability;
44
mod options;
55

66
pub use self::capability::ChunkUploadCapability;
7-
pub use self::options::ChunkUploadOptions;
7+
pub use self::options::ChunkServerOptions;

src/api/data_types/chunking/upload/options.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ use serde::Deserialize;
22

33
use super::{ChunkCompression, ChunkHashAlgorithm, ChunkUploadCapability};
44

5+
/// Chunk upload options which are set by the Sentry server.
56
#[derive(Debug, Deserialize)]
67
#[serde(rename_all = "camelCase")]
7-
pub struct ChunkUploadOptions {
8+
pub struct ChunkServerOptions {
89
pub url: String,
910
#[serde(rename = "chunksPerRequest")]
1011
pub max_chunks: u64,
@@ -24,7 +25,7 @@ pub struct ChunkUploadOptions {
2425
pub accept: Vec<ChunkUploadCapability>,
2526
}
2627

27-
impl ChunkUploadOptions {
28+
impl ChunkServerOptions {
2829
/// Returns whether the given capability is accepted by the chunk upload endpoint.
2930
pub fn supports(&self, capability: ChunkUploadCapability) -> bool {
3031
self.accept.contains(&capability)

src/api/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,11 +936,11 @@ impl<'a> AuthenticatedApi<'a> {
936936
}
937937

938938
/// Get the server configuration for chunked file uploads.
939-
pub fn get_chunk_upload_options(&self, org: &str) -> ApiResult<Option<ChunkUploadOptions>> {
939+
pub fn get_chunk_upload_options(&self, org: &str) -> ApiResult<Option<ChunkServerOptions>> {
940940
let url = format!("/organizations/{}/chunk-upload/", PathArg(org));
941941
match self
942942
.get(&url)?
943-
.convert_rnf::<ChunkUploadOptions>(ApiErrorKind::ChunkUploadNotSupported)
943+
.convert_rnf::<ChunkServerOptions>(ApiErrorKind::ChunkUploadNotSupported)
944944
{
945945
Ok(options) => Ok(Some(options)),
946946
Err(error) => {

src/utils/chunks/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rayon::prelude::*;
1919
use rayon::ThreadPoolBuilder;
2020
use sha1_smol::Digest;
2121

22-
use crate::api::{Api, ChunkUploadOptions};
22+
use crate::api::{Api, ChunkServerOptions};
2323
use crate::utils::progress::{ProgressBar, ProgressBarMode, ProgressStyle};
2424

2525
/// Timeout for polling all assemble endpoints.
@@ -164,7 +164,7 @@ impl ItemSize for Chunk<'_> {
164164
/// This function blocks until all chunks have been uploaded.
165165
pub fn upload_chunks(
166166
chunks: &[Chunk<'_>],
167-
chunk_options: &ChunkUploadOptions,
167+
chunk_options: &ChunkServerOptions,
168168
progress_style: ProgressStyle,
169169
) -> Result<()> {
170170
let total_bytes = chunks.iter().map(|&Chunk((_, data))| data.len()).sum();
@@ -190,7 +190,7 @@ pub fn upload_chunks(
190190
info!("using '{}' compression for chunk upload", compression);
191191

192192
// The upload is executed in parallel batches. Each batch aggregates objects
193-
// until it exceeds the maximum size configured in ChunkUploadOptions. We
193+
// until it exceeds the maximum size configured in ChunkServerOptions. We
194194
// keep track of the overall progress and potential errors. If an error
195195
// occurs, all subsequent requests will be cancelled and the error returned.
196196
// Otherwise, the after every successful update, the overall progress is

src/utils/dif_upload.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use zip::result::ZipError;
3434
use zip::{write::FileOptions, ZipArchive, ZipWriter};
3535

3636
use crate::api::{
37-
Api, AssembleDifsRequest, ChunkUploadCapability, ChunkUploadOptions, ChunkedFileState,
37+
Api, AssembleDifsRequest, ChunkServerOptions, ChunkUploadCapability, ChunkedFileState,
3838
};
3939
use crate::config::Config;
4040
use crate::constants::{DEFAULT_MAX_DIF_SIZE, DEFAULT_MAX_WAIT};
@@ -1313,7 +1313,7 @@ where
13131313
/// This function blocks until all chunks have been uploaded.
13141314
fn upload_missing_chunks<T>(
13151315
missing_info: &MissingObjectsInfo<'_, T>,
1316-
chunk_options: &ChunkUploadOptions,
1316+
chunk_options: &ChunkServerOptions,
13171317
) -> Result<()> {
13181318
let (objects, chunks) = missing_info;
13191319

@@ -1519,7 +1519,7 @@ where
15191519
/// Uploads debug info files using the chunk-upload endpoint.
15201520
fn upload_difs_chunked(
15211521
options: &DifUpload,
1522-
chunk_options: &ChunkUploadOptions,
1522+
chunk_options: &ChunkServerOptions,
15231523
) -> Result<(Vec<DebugInfoFile>, bool)> {
15241524
// Search for debug files in the file system and ZIPs
15251525
let found = search_difs(options)?;

src/utils/file_upload.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use symbolic::debuginfo::sourcebundle::{
2222
use url::Url;
2323

2424
use crate::api::NewRelease;
25-
use crate::api::{Api, ChunkUploadCapability, ChunkUploadOptions};
25+
use crate::api::{Api, ChunkServerOptions, ChunkUploadCapability};
2626
use crate::constants::DEFAULT_MAX_WAIT;
2727
use crate::utils::chunks::{upload_chunks, Chunk, ASSEMBLE_POLL_INTERVAL};
2828
use crate::utils::fs::{get_sha1_checksum, get_sha1_checksums, TempFile};
@@ -90,7 +90,7 @@ pub struct UploadContext<'a> {
9090
pub wait: bool,
9191
pub max_wait: Duration,
9292
pub dedupe: bool,
93-
pub chunk_upload_options: Option<&'a ChunkUploadOptions>,
93+
pub chunk_upload_options: Option<&'a ChunkServerOptions>,
9494
}
9595

9696
impl UploadContext<'_> {
@@ -317,7 +317,7 @@ fn poll_assemble(
317317
checksum: Digest,
318318
chunks: &[Digest],
319319
context: &UploadContext,
320-
options: &ChunkUploadOptions,
320+
options: &ChunkServerOptions,
321321
) -> Result<()> {
322322
let progress_style = ProgressStyle::default_spinner().template("{spinner} Processing files...");
323323

@@ -400,7 +400,7 @@ fn poll_assemble(
400400
fn upload_files_chunked(
401401
context: &UploadContext,
402402
files: &SourceFiles,
403-
options: &ChunkUploadOptions,
403+
options: &ChunkServerOptions,
404404
) -> Result<()> {
405405
let archive = build_artifact_bundle(context, files, None)?;
406406

src/utils/proguard/upload.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::time::{Duration, Instant};
1010
use anyhow::Result;
1111
use indicatif::ProgressStyle;
1212

13-
use crate::api::{Api, ChunkUploadOptions, ChunkedFileState};
13+
use crate::api::{Api, ChunkServerOptions, ChunkedFileState};
1414
use crate::utils::chunks;
1515
use crate::utils::chunks::Chunked;
1616
use crate::utils::proguard::ProguardMapping;
@@ -28,7 +28,7 @@ const ASSEMBLE_POLL_TIMEOUT: Duration = Duration::from_secs(120);
2828
/// Returns an error if the mappings fail to assemble, or if the timeout is reached.
2929
pub fn chunk_upload(
3030
mappings: &[ProguardMapping<'_>],
31-
chunk_upload_options: &ChunkUploadOptions,
31+
chunk_upload_options: &ChunkServerOptions,
3232
org: &str,
3333
project: &str,
3434
) -> Result<()> {

0 commit comments

Comments
 (0)