src/backup.rs; use a macro to define PROXMOX_BACKUP_PROTOCOL_ID_V1
So that we can include it in static doc strings.
This commit is contained in:
parent
c9ec0956cf
commit
986bef16be
@ -34,7 +34,7 @@ pub fn router() -> Router {
|
||||
pub fn api_method_upgrade_backup() -> ApiAsyncMethod {
|
||||
ApiAsyncMethod::new(
|
||||
upgrade_to_backup_protocol,
|
||||
ObjectSchema::new("Upgraded to backup protocol.")
|
||||
ObjectSchema::new(concat!("Upgraded to backup protocol ('", PROXMOX_BACKUP_PROTOCOL_ID_V1!(), "')."))
|
||||
.required("store", StringSchema::new("Datastore name."))
|
||||
.required("backup-type", StringSchema::new("Backup type.")
|
||||
.format(Arc::new(ApiStringFormat::Enum(&["vm", "ct", "host"]))))
|
||||
@ -66,7 +66,7 @@ fn upgrade_to_backup_protocol(
|
||||
.ok_or_else(|| format_err!("missing Upgrade header"))?
|
||||
.to_str()?;
|
||||
|
||||
if protocols != PROXMOX_BACKUP_PROTOCOL_ID_V1 {
|
||||
if protocols != PROXMOX_BACKUP_PROTOCOL_ID_V1!() {
|
||||
bail!("invalid protocol name");
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ fn upgrade_to_backup_protocol(
|
||||
|
||||
let response = Response::builder()
|
||||
.status(StatusCode::SWITCHING_PROTOCOLS)
|
||||
.header(UPGRADE, HeaderValue::from_static(PROXMOX_BACKUP_PROTOCOL_ID_V1))
|
||||
.header(UPGRADE, HeaderValue::from_static(PROXMOX_BACKUP_PROTOCOL_ID_V1!()))
|
||||
.body(Body::empty())?;
|
||||
|
||||
Ok(Box::new(futures::future::ok(response)))
|
||||
|
@ -102,7 +102,10 @@
|
||||
//!
|
||||
//! Not sure if this is better. TODO
|
||||
|
||||
pub const PROXMOX_BACKUP_PROTOCOL_ID_V1: &str = "proxmox-backup-protocol-v1";
|
||||
#[macro_export]
|
||||
macro_rules! PROXMOX_BACKUP_PROTOCOL_ID_V1 {
|
||||
() => { "proxmox-backup-protocol-v1" }
|
||||
}
|
||||
|
||||
mod chunk_stream;
|
||||
pub use chunk_stream::*;
|
||||
|
@ -23,6 +23,8 @@ use crate::tools::{self, BroadcastFuture, tty};
|
||||
use super::pipe_to_stream::*;
|
||||
use super::merge_known_chunks::*;
|
||||
|
||||
use crate::backup::*;
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AuthInfo {
|
||||
@ -269,7 +271,7 @@ impl HttpClient {
|
||||
|
||||
let enc_ticket = format!("PBSAuthCookie={}", percent_encode(auth.ticket.as_bytes(), DEFAULT_ENCODE_SET));
|
||||
req.headers_mut().insert("Cookie", HeaderValue::from_str(&enc_ticket).unwrap());
|
||||
req.headers_mut().insert("UPGRADE", HeaderValue::from_str(crate::backup::PROXMOX_BACKUP_PROTOCOL_ID_V1).unwrap());
|
||||
req.headers_mut().insert("UPGRADE", HeaderValue::from_str(PROXMOX_BACKUP_PROTOCOL_ID_V1!()).unwrap());
|
||||
|
||||
client.request(req)
|
||||
.map_err(Error::from)
|
||||
@ -635,7 +637,7 @@ impl BackupClient {
|
||||
|
||||
let mut release_capacity = body.release_capacity().clone();
|
||||
|
||||
crate::backup::DigestListDecoder::new(body.map_err(Error::from))
|
||||
DigestListDecoder::new(body.map_err(Error::from))
|
||||
.for_each(move |chunk| {
|
||||
let _ = release_capacity.release_capacity(chunk.len());
|
||||
println!("GOT DOWNLOAD {}", tools::digest_to_hex(&chunk));
|
||||
|
@ -14,6 +14,7 @@ pub mod pxar;
|
||||
|
||||
pub mod section_config;
|
||||
|
||||
#[macro_use]
|
||||
pub mod backup;
|
||||
|
||||
pub mod config;
|
||||
|
Loading…
Reference in New Issue
Block a user