@@ -15,7 +15,7 @@ use symbolic::common::ByteView;
1515use zip:: write:: SimpleFileOptions ;
1616use zip:: { DateTime , ZipWriter } ;
1717
18- use crate :: api:: { Api , AuthenticatedApi , ChunkUploadCapability } ;
18+ use crate :: api:: { Api , AuthenticatedApi , ChunkUploadCapability , ChunkedFileState } ;
1919use crate :: config:: Config ;
2020use crate :: utils:: args:: ArgExt as _;
2121use crate :: utils:: chunks:: { upload_chunks, Chunk } ;
@@ -128,9 +128,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
128128
129129 let config = Config :: current ( ) ;
130130 let ( org, project) = config. get_org_and_project ( matches) ?;
131- let base_url = config. get_base_url ( ) ?;
132131
133- let mut uploaded_paths_and_ids = vec ! [ ] ;
132+ let mut uploaded_paths_and_urls = vec ! [ ] ;
134133 let mut errored_paths_and_reasons = vec ! [ ] ;
135134 for ( path, zip) in normalized_zips {
136135 info ! ( "Uploading file: {}" , path. display( ) ) ;
@@ -143,9 +142,9 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
143142 sha. as_deref ( ) ,
144143 build_configuration,
145144 ) {
146- Ok ( artifact_id ) => {
145+ Ok ( artifact_url ) => {
147146 info ! ( "Successfully uploaded file: {}" , path. display( ) ) ;
148- uploaded_paths_and_ids . push ( ( path. to_path_buf ( ) , artifact_id ) ) ;
147+ uploaded_paths_and_urls . push ( ( path. to_path_buf ( ) , artifact_url ) ) ;
149148 }
150149 Err ( e) => {
151150 debug ! ( "Failed to upload file at path {}: {}" , path. display( ) , e) ;
@@ -169,22 +168,21 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
169168 }
170169 }
171170
172- if uploaded_paths_and_ids . is_empty ( ) {
171+ if uploaded_paths_and_urls . is_empty ( ) {
173172 bail ! ( "Failed to upload any files" ) ;
174173 } else {
175174 println ! (
176175 "Successfully uploaded {} file{} to Sentry" ,
177- uploaded_paths_and_ids . len( ) ,
178- if uploaded_paths_and_ids . len( ) == 1 {
176+ uploaded_paths_and_urls . len( ) ,
177+ if uploaded_paths_and_urls . len( ) == 1 {
179178 ""
180179 } else {
181180 "s"
182181 }
183182 ) ;
184- if uploaded_paths_and_ids. len ( ) < 3 {
185- for ( path, artifact_id) in & uploaded_paths_and_ids {
186- let url = format ! ( "{base_url}/{org}/preprod/{project}/{artifact_id}" ) ;
187- println ! ( " - {} {url}" , path. display( ) ) ;
183+ if uploaded_paths_and_urls. len ( ) < 3 {
184+ for ( path, artifact_url) in & uploaded_paths_and_urls {
185+ println ! ( " - {} {artifact_url}" , path. display( ) ) ;
188186 }
189187 }
190188 }
@@ -346,7 +344,7 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
346344 Ok ( temp_file)
347345}
348346
349- /// Returns artifact id if upload was successful.
347+ /// Returns artifact url if upload was successful.
350348fn upload_file (
351349 api : & AuthenticatedApi ,
352350 bytes : & [ u8 ] ,
@@ -399,15 +397,16 @@ fn upload_file(
399397 // In the normal case we go through this loop exactly twice:
400398 // 1. state=not_found
401399 // server tells us the we need to send every chunk and we do so
402- // 2. artifact_id set so we're done (likely state=created)
400+ // 2. artifact_url set so we're done (likely state=created)
403401 //
404402 // In the case where all the chunks are already on the server we go
405403 // through only once:
406- // 1. state=ok, artifact_id set
404+ // 1. state=created, artifact_url set
407405 //
408406 // In the case where something went wrong (which could be on either
409407 // iteration of the loop) we get:
410- // n. state=err, artifact_id unset
408+ // n. state=error, artifact_url unset
409+
411410 let result = loop {
412411 let response =
413412 api. assemble_mobile_app ( org, project, checksum, & checksums, sha, build_configuration) ?;
@@ -420,16 +419,14 @@ fn upload_file(
420419 ) ;
421420 upload_chunks ( & chunks, & chunk_upload_options, upload_progress_style) ?;
422421 }
423-
424- // is_err() is not_found or error and is_finished() is ok or error, so if both the the
425- // state is error
426- if response. state . is_finished ( ) && response. state . is_err ( ) {
422+
423+ if response. state == ChunkedFileState :: Error {
427424 let message = response. detail . as_deref ( ) . unwrap_or ( "unknown error" ) ;
428425 bail ! ( "Failed to process uploaded files: {}" , message) ;
429426 }
430427
431- if let Some ( artifact_id ) = response. artifact_id {
432- break Ok ( artifact_id ) ;
428+ if let Some ( artifact_url ) = response. artifact_url {
429+ break Ok ( artifact_url ) ;
433430 }
434431 } ;
435432
0 commit comments