split the namespace out of BackupGroup/Dir api types
We decided to go this route because it'll most likely be safer in the API as we need to explicitly add namespaces support to the various API endpoints this way. For example, 'pull' should have 2 namespaces: local and remote, and the GroupFilter (which would otherwise contain exactly *one* namespace parameter) needs to be applied for both sides (to decide what to pull from the remote, and what to *remove* locally as cleanup). The *datastore* types still contain the namespace and have a `.backup_ns()` getter. Note that the datastore's `Display` implementations are no longer safe to use as a deserializable string. Additionally, some datastore based methods now have been exposed via the BackupGroup/BackupDir types to avoid a "round trip" in code. 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
1baf9030ad
commit
133d718fe4
@ -7,7 +7,7 @@ use std::sync::Arc;
|
||||
use futures::future::AbortHandle;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use pbs_api_types::BackupDir;
|
||||
use pbs_api_types::{BackupDir, BackupNamespace};
|
||||
use pbs_datastore::data_blob::DataBlob;
|
||||
use pbs_datastore::data_blob_reader::DataBlobReader;
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
@ -47,6 +47,7 @@ impl BackupReader {
|
||||
client: HttpClient,
|
||||
crypt_config: Option<Arc<CryptConfig>>,
|
||||
datastore: &str,
|
||||
ns: &BackupNamespace,
|
||||
backup: &BackupDir,
|
||||
debug: bool,
|
||||
) -> Result<Arc<BackupReader>, Error> {
|
||||
@ -58,7 +59,6 @@ impl BackupReader {
|
||||
"debug": debug,
|
||||
});
|
||||
|
||||
let ns = backup.ns();
|
||||
if !ns.is_root() {
|
||||
param["backup-ns"] = serde_json::to_value(ns)?;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use tokio::io::AsyncReadExt;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
use pbs_api_types::{BackupDir, HumanByte};
|
||||
use pbs_api_types::{BackupDir, BackupNamespace, HumanByte};
|
||||
use pbs_datastore::data_blob::{ChunkInfo, DataBlob, DataChunkBuilder};
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
@ -86,6 +86,7 @@ impl BackupWriter {
|
||||
client: HttpClient,
|
||||
crypt_config: Option<Arc<CryptConfig>>,
|
||||
datastore: &str,
|
||||
ns: &BackupNamespace,
|
||||
backup: &BackupDir,
|
||||
debug: bool,
|
||||
benchmark: bool,
|
||||
@ -99,7 +100,6 @@ impl BackupWriter {
|
||||
"benchmark": benchmark
|
||||
});
|
||||
|
||||
let ns = backup.ns();
|
||||
if !ns.is_root() {
|
||||
param["backup-ns"] = serde_json::to_value(ns)?;
|
||||
}
|
||||
|
@ -292,8 +292,16 @@ pub async fn complete_server_file_name_do(param: &HashMap<String, String>) -> Ve
|
||||
_ => return result,
|
||||
};
|
||||
|
||||
let ns: pbs_api_types::BackupNamespace = match param.get("ns") {
|
||||
Some(ns) => match ns.parse() {
|
||||
Ok(v) => v,
|
||||
_ => return result,
|
||||
},
|
||||
_ => return result,
|
||||
};
|
||||
|
||||
let query = json_object_to_query(json!({
|
||||
"backup-ns": snapshot.group.ns,
|
||||
"backup-ns": ns,
|
||||
"backup-type": snapshot.group.ty,
|
||||
"backup-id": snapshot.group.id,
|
||||
"backup-time": snapshot.time,
|
||||
|
Reference in New Issue
Block a user