Skip to content

Commit 8c4cf18

Browse files
feat(preprod): use artifact url from response
1 parent 17d95d4 commit 8c4cf18

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/api/data_types/chunking/mobile_app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ pub struct AssembleMobileAppResponse {
2020
pub state: ChunkedFileState,
2121
pub missing_chunks: Vec<Digest>,
2222
pub detail: Option<String>,
23-
pub artifact_id: Option<String>,
23+
pub artifact_url: Option<String>,
2424
}

src/commands/mobile_app/upload.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
117117

118118
let config = Config::current();
119119
let (org, project) = config.get_org_and_project(matches)?;
120-
let base_url = config.get_base_url()?;
121120

122-
let mut uploaded_paths_and_ids = vec![];
121+
let mut uploaded_paths_and_urls = vec![];
123122
let mut errored_paths_and_reasons = vec![];
124123
for (path, zip) in normalized_zips {
125124
info!("Uploading file: {}", path.display());
@@ -132,9 +131,9 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
132131
sha.as_deref(),
133132
build_configuration,
134133
) {
135-
Ok(artifact_id) => {
134+
Ok(artifact_url) => {
136135
info!("Successfully uploaded file: {}", path.display());
137-
uploaded_paths_and_ids.push((path.to_path_buf(), artifact_id));
136+
uploaded_paths_and_urls.push((path.to_path_buf(), artifact_url));
138137
}
139138
Err(e) => {
140139
debug!("Failed to upload file at path {}: {}", path.display(), e);
@@ -158,22 +157,28 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
158157
}
159158
}
160159

161-
if uploaded_paths_and_ids.is_empty() {
160+
if uploaded_paths_and_urls.is_empty() {
162161
bail!("Failed to upload any files");
163162
} else {
164163
println!(
165164
"Successfully uploaded {} file{} to Sentry",
166-
uploaded_paths_and_ids.len(),
167-
if uploaded_paths_and_ids.len() == 1 {
165+
uploaded_paths_and_urls.len(),
166+
if uploaded_paths_and_urls.len() == 1 {
168167
""
169168
} else {
170169
"s"
171170
}
172171
);
172+
<<<<<<< Updated upstream
173173
if uploaded_paths_and_ids.len() < 3 {
174174
for (path, artifact_id) in &uploaded_paths_and_ids {
175175
let url = format!("{base_url}/{org}/preprod/{project}/{artifact_id}");
176176
println!(" - {} ({url})", path.display());
177+
=======
178+
if uploaded_paths_and_urls.len() < 3 {
179+
for (path, artifact_url) in &uploaded_paths_and_urls {
180+
println!(" - {} {artifact_url}", path.display());
181+
>>>>>>> Stashed changes
177182
}
178183
}
179184
}
@@ -283,7 +288,7 @@ fn handle_directory(path: &Path) -> Result<TempFile> {
283288
normalize_directory(path, temp_dir.path())
284289
}
285290

286-
/// Returns artifact id if upload was successful.
291+
/// Returns artifact url if upload was successful.
287292
fn upload_file(
288293
api: &AuthenticatedApi,
289294
bytes: &[u8],
@@ -336,15 +341,16 @@ fn upload_file(
336341
// In the normal case we go through this loop exactly twice:
337342
// 1. state=not_found
338343
// server tells us the we need to send every chunk and we do so
339-
// 2. artifact_id set so we're done (likely state=created)
344+
// 2. artifact_url set so we're done (likely state=created)
340345
//
341346
// In the case where all the chunks are already on the server we go
342347
// through only once:
343-
// 1. state=ok, artifact_id set
348+
// 1. state=created, artifact_url set
344349
//
345350
// In the case where something went wrong (which could be on either
346351
// iteration of the loop) we get:
347-
// n. state=err, artifact_id unset
352+
// n. state=error, artifact_url unset
353+
348354
let result = loop {
349355
let response =
350356
api.assemble_mobile_app(org, project, checksum, &checksums, sha, build_configuration)?;
@@ -357,16 +363,20 @@ fn upload_file(
357363
);
358364
upload_chunks(&chunks, &chunk_upload_options, upload_progress_style)?;
359365
}
366+
<<<<<<< Updated upstream
360367

361368
// state.is_err() is not the same as this since it also returns
362369
// true for ChunkedFileState::NotFound.
370+
=======
371+
372+
>>>>>>> Stashed changes
363373
if response.state == ChunkedFileState::Error {
364374
let message = response.detail.as_deref().unwrap_or("unknown error");
365375
bail!("Failed to process uploaded files: {}", message);
366376
}
367377

368-
if let Some(artifact_id) = response.artifact_id {
369-
break Ok(artifact_id);
378+
if let Some(artifact_url) = response.artifact_url {
379+
break Ok(artifact_url);
370380
}
371381

372382
if response.state.is_finished() {

0 commit comments

Comments
 (0)