1- use std:: env;
21use std:: io;
32
43use anyhow:: { bail, Error , Result } ;
@@ -8,7 +7,8 @@ use console::style;
87use symbolic:: common:: ByteView ;
98use uuid:: Uuid ;
109
11- use crate :: api:: Api ;
10+ use crate :: api:: ChunkUploadCapability ;
11+ use crate :: api:: { Api , DebugInfoFile } ;
1212use crate :: config:: Config ;
1313use crate :: utils:: android:: dump_proguard_uuids_as_properties;
1414use crate :: utils:: args:: ArgExt as _;
@@ -18,8 +18,6 @@ use crate::utils::proguard::ProguardMapping;
1818use crate :: utils:: system:: QuietExit ;
1919use crate :: utils:: ui:: { copy_with_progress, make_byte_progress_bar} ;
2020
21- const CHUNK_UPLOAD_ENV_VAR : & str = "SENTRY_EXPERIMENTAL_PROGUARD_CHUNK_UPLOAD" ;
22-
2321pub 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( ) ,
0 commit comments