summaryrefslogtreecommitdiffstats
path: root/src/commands/release.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-03-01 08:45:12 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-03-01 08:49:43 +0100
commit184fe5130f8354d303dc521eb6ba047e9434bb54 (patch)
treed3ee3a03f4fe07bce3a58073dcb5fe7c01e932d7 /src/commands/release.rs
parentcd05302918d4bbbe32221951157dd43fd50c3405 (diff)
Add release update functionality
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/commands/release.rs')
-rw-r--r--src/commands/release.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/commands/release.rs b/src/commands/release.rs
index e811cb6..21640ff 100644
--- a/src/commands/release.rs
+++ b/src/commands/release.rs
@@ -132,6 +132,7 @@ 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 now = chrono::offset::Local::now().naive_local();
arts.into_iter()
@@ -150,9 +151,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 !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)