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
@ -8,7 +8,9 @@ use anyhow::{bail, format_err, Error};
|
||||
|
||||
use proxmox_sys::{task_log, WorkerTaskContext};
|
||||
|
||||
use pbs_api_types::{Authid, BackupType, CryptMode, SnapshotVerifyState, VerifyState, UPID};
|
||||
use pbs_api_types::{
|
||||
Authid, BackupNamespace, BackupType, CryptMode, SnapshotVerifyState, VerifyState, UPID,
|
||||
};
|
||||
use pbs_datastore::backup_info::{BackupDir, BackupGroup, BackupInfo};
|
||||
use pbs_datastore::index::IndexFile;
|
||||
use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, FileInfo};
|
||||
@ -324,7 +326,7 @@ pub fn verify_backup_dir(
|
||||
filter: Option<&dyn Fn(&BackupManifest) -> bool>,
|
||||
) -> Result<bool, Error> {
|
||||
let snap_lock = lock_dir_noblock_shared(
|
||||
&verify_worker.datastore.snapshot_path(backup_dir.as_ref()),
|
||||
&backup_dir.full_path(),
|
||||
"snapshot",
|
||||
"locked by another operation",
|
||||
);
|
||||
@ -510,7 +512,13 @@ pub fn verify_all_backups(
|
||||
}
|
||||
|
||||
let filter_by_owner = |group: &BackupGroup| {
|
||||
match (verify_worker.datastore.get_owner(group.as_ref()), &owner) {
|
||||
match (
|
||||
// FIXME: with recursion the namespace needs to come from the iterator...
|
||||
verify_worker
|
||||
.datastore
|
||||
.get_owner(&BackupNamespace::root(), group.as_ref()),
|
||||
&owner,
|
||||
) {
|
||||
(Ok(ref group_owner), Some(owner)) => {
|
||||
group_owner == owner
|
||||
|| (group_owner.is_token()
|
||||
|
Reference in New Issue
Block a user