datastore: move list_backup_groups into Datastore impl
Having that as static method in BackupInfo makes zero sense and just complicates call sites, which need to extract the base_path from the store manually upfront. Mark old fn as deprecated so that we can do the move in a separate step. It's also planned to add an Iterator impl for this to allow more efficient usage in the future. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
bdfa637058
commit
c90dbb5c7b
|
@ -369,6 +369,7 @@ impl BackupInfo {
|
||||||
Ok(files)
|
Ok(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated = "move to datastore"]
|
||||||
pub fn list_backup_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
|
pub fn list_backup_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
|
||||||
let mut list = Vec::new();
|
let mut list = Vec::new();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ use proxmox_sys::{task_log, task_warn};
|
||||||
|
|
||||||
use pbs_api_types::{
|
use pbs_api_types::{
|
||||||
Authid, ChunkOrder, DataStoreConfig, DatastoreTuning, GarbageCollectionStatus, HumanByte,
|
Authid, ChunkOrder, DataStoreConfig, DatastoreTuning, GarbageCollectionStatus, HumanByte,
|
||||||
Operation, UPID,
|
Operation, BACKUP_ID_REGEX, BACKUP_TYPE_REGEX, UPID,
|
||||||
};
|
};
|
||||||
use pbs_config::{open_backup_lockfile, BackupLockGuard, ConfigVersionCache};
|
use pbs_config::{open_backup_lockfile, BackupLockGuard, ConfigVersionCache};
|
||||||
|
|
||||||
|
@ -552,6 +552,38 @@ impl DataStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a in-memory vector for all top-level backup groups of a datatstore
|
||||||
|
pub fn list_backup_groups(&self) -> Result<Vec<BackupGroup>, Error> {
|
||||||
|
let mut list = Vec::new();
|
||||||
|
|
||||||
|
proxmox_sys::fs::scandir(
|
||||||
|
libc::AT_FDCWD,
|
||||||
|
&self.base_path(),
|
||||||
|
&BACKUP_TYPE_REGEX,
|
||||||
|
|l0_fd, backup_type, file_type| {
|
||||||
|
if file_type != nix::dir::Type::Directory {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
proxmox_sys::fs::scandir(
|
||||||
|
l0_fd,
|
||||||
|
backup_type,
|
||||||
|
&BACKUP_ID_REGEX,
|
||||||
|
|_, backup_id, file_type| {
|
||||||
|
if file_type != nix::dir::Type::Directory {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
list.push(BackupGroup::new(backup_type, backup_id));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(list)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn list_images(&self) -> Result<Vec<PathBuf>, Error> {
|
pub fn list_images(&self) -> Result<Vec<PathBuf>, Error> {
|
||||||
let base = self.base_path();
|
let base = self.base_path();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue