@@ -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