Skip to content

Commit ce16b51

Browse files
NicoHinderlingchromy
authored andcommitted
Use URL from backend
1 parent 17d95d4 commit ce16b51

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
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: 17 additions & 18 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,21 @@ 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
);
173-
if uploaded_paths_and_ids.len() < 3 {
174-
for (path, artifact_id) in &uploaded_paths_and_ids {
175-
let url = format!("{base_url}/{org}/preprod/{project}/{artifact_id}");
176-
println!(" - {} ({url})", path.display());
172+
if uploaded_paths_and_urls.len() < 3 {
173+
for (path, artifact_url) in &uploaded_paths_and_urls {
174+
println!(" - {} ({artifact_url})", path.display());
177175
}
178176
}
179177
}
@@ -283,7 +281,7 @@ fn handle_directory(path: &Path) -> Result<TempFile> {
283281
normalize_directory(path, temp_dir.path())
284282
}
285283

286-
/// Returns artifact id if upload was successful.
284+
/// Returns artifact url if upload was successful.
287285
fn upload_file(
288286
api: &AuthenticatedApi,
289287
bytes: &[u8],
@@ -336,15 +334,16 @@ fn upload_file(
336334
// In the normal case we go through this loop exactly twice:
337335
// 1. state=not_found
338336
// 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)
337+
// 2. artifact_url set so we're done (likely state=created)
340338
//
341339
// In the case where all the chunks are already on the server we go
342340
// through only once:
343-
// 1. state=ok, artifact_id set
341+
// 1. state=created, artifact_url set
344342
//
345343
// In the case where something went wrong (which could be on either
346344
// iteration of the loop) we get:
347-
// n. state=err, artifact_id unset
345+
// n. state=error, artifact_url unset
346+
348347
let result = loop {
349348
let response =
350349
api.assemble_mobile_app(org, project, checksum, &checksums, sha, build_configuration)?;
@@ -365,13 +364,13 @@ fn upload_file(
365364
bail!("Failed to process uploaded files: {}", message);
366365
}
367366

368-
if let Some(artifact_id) = response.artifact_id {
369-
break Ok(artifact_id);
367+
if let Some(artifact_url) = response.artifact_url {
368+
break Ok(artifact_url);
370369
}
371370

372371
if response.state.is_finished() {
373372
bail!(
374-
"File upload is_finished() but did not succeeded (returning artifact_id) or error"
373+
"File upload is_finished() but did not succeeded or error"
375374
);
376375
}
377376
};

tests/integration/mobile_app/upload.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn command_mobile_app_upload_apk_all_uploaded() {
8686
"POST",
8787
"/api/0/projects/wat-org/wat-project/files/preprodartifacts/assemble/",
8888
)
89-
.with_response_body(r#"{"state":"ok","missingChunks":[],"artifactId":"42"}"#),
89+
.with_response_body(r#"{"state":"ok","missingChunks":[],"artifactUrl":"https://sentry.io/wat-org/preprod/wat-project/42"}"#),
9090
)
9191
.register_trycmd_test("mobile_app/mobile_app-upload-apk-all-uploaded.trycmd")
9292
.with_default_token();
@@ -170,7 +170,7 @@ fn command_mobile_app_upload_apk_chunked() {
170170
r#"{
171171
"state": "ok",
172172
"missingChunks": [],
173-
"artifactId": "42"
173+
"artifactUrl": "http://sentry.io/wat-org/preprod/wat-project/42"
174174
}"#
175175
}
176176
.into()
@@ -225,7 +225,7 @@ fn command_mobile_app_upload_ipa_chunked() {
225225
r#"{
226226
"state": "ok",
227227
"missingChunks": [],
228-
"artifactId": "some-text-id"
228+
"artifactUrl": "http://sentry.io/wat-org/preprod/wat-project/some-text-id"
229229
}"#
230230
}
231231
.into()

0 commit comments

Comments
 (0)