cli: tape key-restore: print more info for better ux
as getting the marker error if we passed valid json (but not valid key) is confusing Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
ede9dc0d1a
commit
1fd46218ea
@ -228,12 +228,13 @@ async fn restore_key(
|
||||
let key = if serde_json::from_str::<KeyConfig>(&data).is_ok() {
|
||||
&data
|
||||
} else {
|
||||
println!("key data seems not like a valid JSON key, trying to parse paper-key format");
|
||||
const BEGIN_MARKER: &str = "-----BEGIN PROXMOX BACKUP KEY-----";
|
||||
const END_MARKER: &str = "-----END PROXMOX BACKUP KEY-----";
|
||||
// exported paperkey-file
|
||||
let start = data
|
||||
.find(BEGIN_MARKER)
|
||||
.ok_or_else(|| format_err!("cannot find key start marker"))?
|
||||
.ok_or_else(|| format_err!("cannot find a paper-key format start marker"))?
|
||||
+ BEGIN_MARKER.len();
|
||||
let data_remain = &data[start..];
|
||||
let end = data_remain
|
||||
|
Loading…
Reference in New Issue
Block a user