make datastore BackupGroup/Dir ctors private
And use the api-types for their contents. These are supposed to be instances for a datastore, the pure specifications are the ones in pbs_api_types which should be preferred in crates like clients which do not need to deal with the datastore directly. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -576,7 +576,7 @@ pub fn backup_snapshot(
|
||||
) -> Result<bool, Error> {
|
||||
task_log!(worker, "backup snapshot {}", snapshot);
|
||||
|
||||
let snapshot_reader = match SnapshotReader::new(datastore.clone(), snapshot.clone()) {
|
||||
let snapshot_reader = match SnapshotReader::new(datastore.clone(), (&snapshot).into()) {
|
||||
Ok(reader) => reader,
|
||||
Err(err) => {
|
||||
// ignore missing snapshots and continue
|
||||
|
@ -13,7 +13,6 @@ use pbs_api_types::{
|
||||
MEDIA_POOL_NAME_SCHEMA, MEDIA_UUID_SCHEMA, PRIV_TAPE_AUDIT, VAULT_NAME_SCHEMA,
|
||||
};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::backup_info::BackupDir;
|
||||
|
||||
use crate::tape::{
|
||||
changer::update_online_status, media_catalog_snapshot_list, Inventory, MediaCatalog, MediaPool,
|
||||
@ -439,15 +438,15 @@ pub fn list_content(
|
||||
.unwrap_or_else(|_| set.uuid.to_string());
|
||||
|
||||
for (store, snapshot) in media_catalog_snapshot_list(status_path, &media_id)? {
|
||||
let backup_dir: BackupDir = snapshot.parse()?;
|
||||
let backup_dir: pbs_api_types::BackupDir = snapshot.parse()?;
|
||||
|
||||
if let Some(backup_type) = filter.backup_type {
|
||||
if backup_dir.group().backup_type() != backup_type {
|
||||
if backup_dir.ty() != backup_type {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(ref backup_id) = filter.backup_id {
|
||||
if backup_dir.group().backup_id() != backup_id {
|
||||
if backup_dir.id() != backup_id {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -462,7 +461,7 @@ pub fn list_content(
|
||||
seq_nr: set.seq_nr,
|
||||
snapshot: snapshot.to_owned(),
|
||||
store: store.to_owned(),
|
||||
backup_time: backup_dir.backup_time(),
|
||||
backup_time: backup_dir.time,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use pbs_api_types::{
|
||||
TAPE_RESTORE_SNAPSHOT_SCHEMA, UPID_SCHEMA,
|
||||
};
|
||||
use pbs_config::CachedUserInfo;
|
||||
use pbs_datastore::backup_info::BackupDir;
|
||||
use pbs_datastore::dynamic_index::DynamicIndexReader;
|
||||
use pbs_datastore::fixed_index::FixedIndexReader;
|
||||
use pbs_datastore::index::IndexFile;
|
||||
@ -423,7 +422,7 @@ fn restore_list_worker(
|
||||
let snapshot = split
|
||||
.next()
|
||||
.ok_or_else(|| format_err!("invalid snapshot:{}", store_snapshot))?;
|
||||
let backup_dir: BackupDir = snapshot.parse()?;
|
||||
let backup_dir: pbs_api_types::BackupDir = snapshot.parse()?;
|
||||
|
||||
let datastore = store_map.get_datastore(source_datastore).ok_or_else(|| {
|
||||
format_err!(
|
||||
@ -433,7 +432,7 @@ fn restore_list_worker(
|
||||
})?;
|
||||
|
||||
let (owner, _group_lock) =
|
||||
datastore.create_locked_backup_group(backup_dir.group(), restore_owner)?;
|
||||
datastore.create_locked_backup_group(backup_dir.as_ref(), restore_owner)?;
|
||||
if restore_owner != &owner {
|
||||
// only the owner is allowed to create additional snapshots
|
||||
bail!(
|
||||
@ -577,7 +576,7 @@ fn restore_list_worker(
|
||||
let snapshot = split
|
||||
.next()
|
||||
.ok_or_else(|| format_err!("invalid snapshot:{}", store_snapshot))?;
|
||||
let backup_dir: BackupDir = snapshot.parse()?;
|
||||
let backup_dir: pbs_api_types::BackupDir = snapshot.parse()?;
|
||||
|
||||
let datastore = store_map.get_datastore(source_datastore).ok_or_else(|| {
|
||||
format_err!("unexpected source datastore: {}", source_datastore)
|
||||
@ -1037,12 +1036,12 @@ fn restore_archive<'a>(
|
||||
snapshot
|
||||
);
|
||||
|
||||
let backup_dir: BackupDir = snapshot.parse()?;
|
||||
let backup_dir: pbs_api_types::BackupDir = snapshot.parse()?;
|
||||
|
||||
if let Some((store_map, authid)) = target.as_ref() {
|
||||
if let Some(datastore) = store_map.get_datastore(&datastore_name) {
|
||||
let (owner, _group_lock) =
|
||||
datastore.create_locked_backup_group(backup_dir.group(), authid)?;
|
||||
datastore.create_locked_backup_group(backup_dir.as_ref(), authid)?;
|
||||
if *authid != &owner {
|
||||
// only the owner is allowed to create additional snapshots
|
||||
bail!(
|
||||
@ -1054,7 +1053,7 @@ fn restore_archive<'a>(
|
||||
}
|
||||
|
||||
let (rel_path, is_new, _snap_lock) =
|
||||
datastore.create_locked_backup_dir(&backup_dir)?;
|
||||
datastore.create_locked_backup_dir(backup_dir.as_ref())?;
|
||||
let mut path = datastore.base_path();
|
||||
path.push(rel_path);
|
||||
|
||||
|
Reference in New Issue
Block a user