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