api-types: introduce BackupType enum and Group/Dir api types
The type is a real enum. All are API types and implement Display and FromStr. The ordering is the same as it is in pbs-datastore. Also, they are now flattened into a few structs instead of being copied manually. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
33eb23d57e
commit
988d575dbb
@ -7,6 +7,7 @@ use std::sync::Arc;
|
||||
use futures::future::AbortHandle;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use pbs_api_types::BackupType;
|
||||
use pbs_datastore::data_blob::DataBlob;
|
||||
use pbs_datastore::data_blob_reader::DataBlobReader;
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
@ -46,7 +47,7 @@ impl BackupReader {
|
||||
client: HttpClient,
|
||||
crypt_config: Option<Arc<CryptConfig>>,
|
||||
datastore: &str,
|
||||
backup_type: &str,
|
||||
backup_type: BackupType,
|
||||
backup_id: &str,
|
||||
backup_time: i64,
|
||||
debug: bool,
|
||||
|
@ -12,7 +12,7 @@ use tokio::io::AsyncReadExt;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
use pbs_api_types::HumanByte;
|
||||
use pbs_api_types::{BackupType, HumanByte};
|
||||
use pbs_datastore::data_blob::{ChunkInfo, DataBlob, DataChunkBuilder};
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
@ -86,7 +86,7 @@ impl BackupWriter {
|
||||
client: HttpClient,
|
||||
crypt_config: Option<Arc<CryptConfig>>,
|
||||
datastore: &str,
|
||||
backup_type: &str,
|
||||
backup_type: BackupType,
|
||||
backup_id: &str,
|
||||
backup_time: i64,
|
||||
debug: bool,
|
||||
|
@ -265,6 +265,13 @@ pub async fn complete_backup_snapshot_do(param: &HashMap<String, String>) -> Vec
|
||||
item["backup-type"].as_str(),
|
||||
item["backup-time"].as_i64(),
|
||||
) {
|
||||
let backup_type = match backup_type.parse() {
|
||||
Ok(ty) => ty,
|
||||
Err(_) => {
|
||||
// FIXME: print error in completion?
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if let Ok(snapshot) = BackupDir::new(backup_type, backup_id, backup_time) {
|
||||
result.push(snapshot.relative_path().to_str().unwrap().to_owned());
|
||||
}
|
||||
|
Reference in New Issue
Block a user