]> git.proxmox.com Git - proxmox-backup.git/commitdiff
manager cli: disk wipe: ask over stdout and drop now useless loop
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 29 Nov 2023 13:51:26 +0000 (14:51 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 29 Nov 2023 13:51:26 +0000 (14:51 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/bin/proxmox_backup_manager/disk.rs

index e0056f6c18b014de9d2ffefdb9325c3b3d0cef67..9c55a989b05466b90442bdbbc1b7c86e4bb19559 100644 (file)
@@ -155,21 +155,17 @@ async fn wipe_disk(mut param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<
 
     // If we're on a TTY, query the user
     if std::io::stdin().is_terminal() {
-        loop {
-            eprintln!("You are about to wipe block device {}.", param["disk"]);
-            eprint!("Are you sure you want to continue? (y/N): ");
-            let _ = std::io::stdout().flush();
-            use std::io::{BufRead, BufReader};
-            let mut line = String::new();
-            match BufReader::new(std::io::stdin()).read_line(&mut line) {
-                Ok(_) => {
-                    match line.trim() {
-                        "y" | "Y" => break,
-                        _ => bail!("Aborting."),
-                    }
-                }
-                Err(err) => bail!("Failed to read line - {err}."),
-            }
+        println!("You are about to wipe block device {}.", param["disk"]);
+        print!("Are you sure you want to continue? (y/N): ");
+        let _ = std::io::stdout().flush();
+        use std::io::{BufRead, BufReader};
+        let mut line = String::new();
+        match BufReader::new(std::io::stdin()).read_line(&mut line) {
+            Ok(_) => match line.trim() {
+                "y" | "Y" => (), // continue
+                _ => bail!("Aborting."),
+            },
+            Err(err) => bail!("Failed to read line - {err}."),
         }
     }