Skip to content

Commit 603cd5a

Browse files
wip
1 parent 569f70a commit 603cd5a

File tree

3 files changed

+46
-61
lines changed

3 files changed

+46
-61
lines changed

src/commands/upload_proguard.rs

Lines changed: 45 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::env;
21
use std::io;
32

43
use anyhow::{bail, Error, Result};
@@ -8,7 +7,8 @@ use console::style;
87
use symbolic::common::ByteView;
98
use uuid::Uuid;
109

11-
use crate::api::Api;
10+
use crate::api::ChunkUploadCapability;
11+
use crate::api::{Api, DebugInfoFile};
1212
use crate::config::Config;
1313
use crate::utils::android::dump_proguard_uuids_as_properties;
1414
use crate::utils::args::ArgExt as _;
@@ -18,8 +18,6 @@ use crate::utils::proguard::ProguardMapping;
1818
use crate::utils::system::QuietExit;
1919
use crate::utils::ui::{copy_with_progress, make_byte_progress_bar};
2020

21-
const CHUNK_UPLOAD_ENV_VAR: &str = "SENTRY_EXPERIMENTAL_PROGUARD_CHUNK_UPLOAD";
22-
2321
pub fn make_command(command: Command) -> Command {
2422
command
2523
.about("Upload ProGuard mapping files to a project.")
@@ -167,67 +165,55 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
167165
let api = Api::current();
168166
let config = Config::current();
169167

170-
// Don't initialize these until we confirm the user did not pass the --no-upload flag,
171-
// or if we are using chunked uploading. This is because auth token, org, and project
172-
// are not needed for the no-upload case.
173-
let authenticated_api;
174-
let (org, project);
168+
if mappings.is_empty() && matches.get_flag("require_one") {
169+
println!();
170+
eprintln!("{}", style("error: found no mapping files to upload").red());
171+
return Err(QuietExit(1).into());
172+
}
175173

176-
if env::var(CHUNK_UPLOAD_ENV_VAR) == Ok("1".into()) {
177-
log::warn!(
178-
"EXPERIMENTAL FEATURE: Uploading proguard mappings using chunked uploading. \
179-
Some functionality may be unavailable when using chunked uploading. Please unset \
180-
the {CHUNK_UPLOAD_ENV_VAR} variable if you encounter any \
181-
problems."
182-
);
174+
// write UUIDs into the mapping file.
175+
if let Some(p) = matches.get_one::<String>("write_properties") {
176+
let uuids: Vec<_> = mappings.iter().map(|x| x.uuid()).collect();
177+
dump_proguard_uuids_as_properties(p, &uuids)?;
178+
}
183179

184-
authenticated_api = api.authenticated()?;
185-
(org, project) = config.get_org_and_project(matches)?;
180+
if matches.get_flag("no_upload") {
181+
println!("{} skipping upload.", style(">").dim());
182+
return Ok(());
183+
}
184+
185+
let authenticated_api = api.authenticated()?;
186+
let (org, project) = config.get_org_and_project(matches)?;
186187

187-
let chunk_upload_options = authenticated_api.get_chunk_upload_options(&org)?;
188+
let chunk_upload_options = authenticated_api.get_chunk_upload_options(&org)?;
188189

190+
if chunk_upload_options.supports(ChunkUploadCapability::Proguard) {
189191
proguard::chunk_upload(&mappings, chunk_upload_options, &org, &project)?;
190192
} else {
191-
if mappings.is_empty() && matches.get_flag("require_one") {
192-
println!();
193-
eprintln!("{}", style("error: found no mapping files to upload").red());
194-
return Err(QuietExit(1).into());
195-
}
196-
197-
println!("{} compressing mappings", style(">").dim());
198-
let tf = TempFile::create()?;
199-
{
200-
let mut zip = zip::ZipWriter::new(tf.open()?);
201-
for mapping in &mappings {
202-
let pb = make_byte_progress_bar(mapping.len() as u64);
203-
zip.start_file(
204-
format!("proguard/{}.txt", mapping.uuid()),
205-
zip::write::SimpleFileOptions::default(),
206-
)?;
207-
copy_with_progress(&pb, &mut mapping.as_ref(), &mut zip)?;
208-
pb.finish_and_clear();
209-
}
210-
}
211-
212-
// write UUIDs into the mapping file.
213-
if let Some(p) = matches.get_one::<String>("write_properties") {
214-
let uuids: Vec<_> = mappings.iter().map(|x| x.uuid()).collect();
215-
dump_proguard_uuids_as_properties(p, &uuids)?;
216-
}
217-
218-
if matches.get_flag("no_upload") {
219-
println!("{} skipping upload.", style(">").dim());
220-
return Ok(());
221-
}
222-
223-
println!("{} uploading mappings", style(">").dim());
224-
(org, project) = config.get_org_and_project(matches)?;
225-
226-
authenticated_api = api.authenticated()?;
227-
228-
let rv = authenticated_api
229-
.region_specific(&org)
230-
.upload_dif_archive(&project, tf.path())?;
193+
// println!("{} compressing mappings", style(">").dim());
194+
// let tf = TempFile::create()?;
195+
// {
196+
// let mut zip = zip::ZipWriter::new(tf.open()?);
197+
// for mapping in &mappings {
198+
// let pb = make_byte_progress_bar(mapping.len() as u64);
199+
// zip.start_file(
200+
// format!("proguard/{}.txt", mapping.uuid()),
201+
// zip::write::SimpleFileOptions::default(),
202+
// )?;
203+
// copy_with_progress(&pb, &mut mapping.as_ref(), &mut zip)?;
204+
// pb.finish_and_clear();
205+
// }
206+
// }
207+
208+
// println!("{} uploading mappings", style(">").dim());
209+
// (org, project) = config.get_org_and_project(matches)?;
210+
211+
// authenticated_api = api.authenticated()?;
212+
213+
// let rv = authenticated_api
214+
// .region_specific(&org)
215+
// .upload_dif_archive(&project, tf.path())?;
216+
let rv: Vec<DebugInfoFile> = todo!();
231217
println!(
232218
"{} Uploaded a total of {} new mapping files",
233219
style(">").dim(),

tests/integration/_responses/debug_files/get-chunk-upload.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"concurrency": 8,
88
"hashAlgorithm": "sha1",
99
"compression": ["gzip"],
10-
"accept": ["debug_files", "release_files", "pdbs", "portablepdbs", "sources", "bcsymbolmaps"]
10+
"accept": ["debug_files", "release_files", "pdbs", "portablepdbs", "sources", "bcsymbolmaps", "proguard"]
1111
}

tests/integration/upload_proguard.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ fn chunk_upload_already_there() {
7272
"tests/integration/_fixtures/upload_proguard/mapping.txt",
7373
])
7474
.with_default_token()
75-
.env("SENTRY_EXPERIMENTAL_PROGUARD_CHUNK_UPLOAD", "1")
7675
.run_and_assert(AssertCommand::Success)
7776
}
7877

0 commit comments

Comments
 (0)