src/bin/proxmox-backup-client.rs: correctly strip file extension

This commit is contained in:
Dietmar Maurer 2019-03-06 11:18:46 +01:00
parent 9f91249351
commit 2ae7d196b9
1 changed files with 14 additions and 9 deletions

View File

@ -421,9 +421,11 @@ fn restore(
"archive-name": file, "archive-name": file,
}))?; }))?;
if file.ends_with(".catar.didx") {
let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store, query); let path = format!("api2/json/admin/datastore/{}/catar?{}", repo.store, query);
let mut target = std::path::PathBuf::from(target_path); let mut target = std::path::PathBuf::from(target_path);
target.push(file); target.push(file);
target.set_extension("");
let fh = std::fs::OpenOptions::new() let fh = std::fs::OpenOptions::new()
.create_new(true) .create_new(true)
@ -432,6 +434,9 @@ fn restore(
println!("DOWNLOAD FILE {} to {:?}", path, target); println!("DOWNLOAD FILE {} to {:?}", path, target);
client.download(&path, Box::new(fh))?; client.download(&path, Box::new(fh))?;
} else {
bail!("unknown file extensions - unable to download '{}'", file);
}
} }
Ok(Value::Null) Ok(Value::Null)