summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-03-01 18:23:42 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-03-01 18:23:42 +0100
commitd74152b84c54a34b689b4bdd624669d885921a93 (patch)
tree10adcbfad8894f2c74a84cfbc163012ab4a6b03c
parentbd90201b77c0b6b7b5655441c04b5da7bfb8e112 (diff)
parentb0a5ccbf467e7e9aa5c73062e91c39a017c9602a (diff)
Merge branch 'release-update'
-rw-r--r--src/cli.rs13
-rw-r--r--src/commands/release.rs14
2 files changed, 25 insertions, 2 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 79d8ccc..0f45984 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -770,6 +770,19 @@ pub fn cli<'a>() -> App<'a> {
.value_name("VERSION")
.about("The exact version of the package (string match)")
)
+ .arg(Arg::new("package_do_update")
+ .required(false)
+ .multiple(false)
+ .long("update")
+ .about("Do update a package if it already exists in the release store")
+ )
+ .arg(Arg::new("noninteractive")
+ .required(false)
+ .multiple(false)
+ .long("non-interactive")
+ .about("Dont be interactive (only with --update at the moment)")
+ .requires("package_do_update")
+ )
)
)
diff --git a/src/commands/release.rs b/src/commands/release.rs
index e811cb6..65641d5 100644
--- a/src/commands/release.rs
+++ b/src/commands/release.rs
@@ -132,6 +132,8 @@ async fn new_release(
let staging_base: &PathBuf = &config.staging_directory().join(submit.uuid.to_string());
let release_store = crate::db::models::ReleaseStore::create(&conn, release_store_name)?;
+ let do_update = matches.is_present("package_do_update");
+ let interactive = !matches.is_present("noninteractive");
let now = chrono::offset::Local::now().naive_local();
arts.into_iter()
@@ -150,9 +152,17 @@ async fn new_release(
art
);
Err(anyhow!("Not a file: {}", art_path.display()))
- } else if dest_path.exists() {
- Err(anyhow!("Does already exist: {}", dest_path.display()))
} else {
+ if dest_path.exists() && !do_update {
+ return Err(anyhow!("Does already exist: {}", dest_path.display()));
+ } else if dest_path.exists() && do_update {
+ writeln!(std::io::stderr(), "Going to update: {}", dest_path.display())?;
+ if interactive && !dialoguer::Confirm::new().with_prompt("Continue?").interact()? {
+ return Err(anyhow!("Does already exist: {} and update was denied", dest_path.display()));
+ }
+ }
+
+ // else !dest_path.exists()
tokio::fs::rename(art_path, dest_path)
.await
.map_err(Error::from)