Skip to content

Commit c730db1

Browse files
committed
tyler/fix-on-conflict
1 parent 78c28d4 commit c730db1

File tree

2 files changed

+33
-42
lines changed

2 files changed

+33
-42
lines changed

crates/cli/src/subcommands/dev.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,15 +413,14 @@ async fn generate_build_and_publish(
413413
ClearMode::OnConflict => "on-conflict",
414414
};
415415
let mut publish_args = vec![
416-
"publish",
417-
database_name,
418-
"--project-path",
419-
project_path_str,
420-
"--yes",
421-
"--delete-data",
422-
clear_flag,
416+
"publish".to_string(),
417+
database_name.to_string(),
418+
"--project-path".to_string(),
419+
project_path_str.to_string(),
420+
"--yes".to_string(),
421+
format!("--delete-data={}", clear_flag),
423422
];
424-
publish_args.extend_from_slice(&["--server", server]);
423+
publish_args.extend_from_slice(&["--server".to_string(), server.to_string()]);
425424

426425
let publish_cmd = publish::cli();
427426
let publish_matches = publish_cmd

crates/cli/src/subcommands/publish.rs

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -175,46 +175,26 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
175175
let domain = percent_encoding::percent_encode(name_or_identity.as_bytes(), encode_set);
176176
let mut builder = client.put(format!("{database_host}/v1/database/{domain}"));
177177

178-
if clear_database != ClearMode::Always {
179-
builder = apply_pre_publish_if_needed(
180-
builder,
181-
&client,
182-
&database_host,
183-
&domain.to_string(),
184-
host_type,
185-
&program_bytes,
186-
&auth_header,
187-
clear_database,
188-
force_break_clients,
189-
force,
190-
)
191-
.await?;
192-
}
178+
builder = apply_pre_publish_if_needed(
179+
builder,
180+
&client,
181+
&database_host,
182+
name_or_identity,
183+
&domain.to_string(),
184+
host_type,
185+
&program_bytes,
186+
&auth_header,
187+
clear_database,
188+
force_break_clients,
189+
force,
190+
)
191+
.await?;
193192

194193
builder
195194
} else {
196195
client.post(format!("{database_host}/v1/database"))
197196
};
198197

199-
if clear_database == ClearMode::Always || clear_database == ClearMode::OnConflict {
200-
// Note: `name_or_identity` should be set, because it is `required` in the CLI arg config.
201-
println!(
202-
"This will DESTROY the current {} module, and ALL corresponding data.",
203-
name_or_identity.unwrap()
204-
);
205-
if !y_or_n(
206-
force,
207-
format!(
208-
"Are you sure you want to proceed? [deleting {}]",
209-
name_or_identity.unwrap()
210-
)
211-
.as_str(),
212-
)? {
213-
println!("Aborting");
214-
return Ok(());
215-
}
216-
builder = builder.query(&[("clear", true)]);
217-
}
218198
if let Some(n) = num_replicas {
219199
eprintln!("WARNING: Use of unstable option `--num-replicas`.\n");
220200
builder = builder.query(&[("num_replicas", *n)]);
@@ -334,6 +314,7 @@ async fn apply_pre_publish_if_needed(
334314
mut builder: reqwest::RequestBuilder,
335315
client: &reqwest::Client,
336316
base_url: &str,
317+
name_or_identity: &str,
337318
domain: &String,
338319
host_type: &str,
339320
program_bytes: &[u8],
@@ -367,6 +348,17 @@ async fn apply_pre_publish_if_needed(
367348
println!("{}", manual.reason);
368349
println!("Proceeding with database clear due to --delete-data=always.");
369350
}
351+
println!(
352+
"This will DESTROY the current {} module, and ALL corresponding data.",
353+
name_or_identity
354+
);
355+
if !y_or_n(
356+
force,
357+
format!("Are you sure you want to proceed? [deleting {}]", name_or_identity).as_str(),
358+
)? {
359+
anyhow::bail!("Aborting");
360+
}
361+
builder = builder.query(&[("clear", true)]);
370362
}
371363
PrePublishResult::AutoMigrate(auto) => {
372364
println!("{}", auto.migrate_plan);

0 commit comments

Comments
 (0)