[pbs-devel] [RFC proxmox-backup 2/4] datastore: allow to specify sub-directory for index file listing
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Apr 18 11:38:52 CEST 2025
Am 16.04.25 um 16:18 schrieb Christian Ebner:
> Extend the list_index_files helper to allow passing a sub-directory
> to it. This will be used to fetch only index files from the `.trash`
> directory, ignored by regular listing since hidden folders are not
> considered.
>
> Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
> ---
> pbs-datastore/src/datastore.rs | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
> index 3fde8b871..97b78f000 100644
> --- a/pbs-datastore/src/datastore.rs
> +++ b/pbs-datastore/src/datastore.rs
> @@ -972,8 +972,15 @@ impl DataStore {
> /// The filesystem is walked recursevly to detect index files based on their archive type based
> /// on the filename. This however excludes the chunks folder, hidden files and does not follow
> /// symlinks.
> - fn list_index_files(&self) -> Result<HashSet<PathBuf>, Error> {
> - let base = self.base_path();
> + /// If a subdirectory is provided, only that is scanned for index files.
> + fn list_index_files(&self, subdir: Option<PathBuf>) -> Result<HashSet<PathBuf>, Error> {
it might be a tiny bit nicer to add a new list_index_files_from_path
that shares the implementation with this one here. While it's not pub
and there is only one use size, it's still minimally nicer to have this
encoded in the method name, at least when reading the call site and
wondering what None means here.
> + let mut base = self.base_path();
> + if let Some(subdir) = subdir {
> + base.push(subdir);
> + if !base.exists() {
> + return Ok(HashSet::new());
> + }
> + }
>
> let mut list = HashSet::new();
>
> @@ -1132,7 +1139,7 @@ impl DataStore {
> // seen by the regular logic and the user is informed by the garbage collection run about
> // the detected index files not following the iterators logic.
>
> - let mut unprocessed_index_list = self.list_index_files()?;
> + let mut unprocessed_index_list = self.list_index_files(None)?;
> let mut index_count = unprocessed_index_list.len();
>
> let mut chunk_lru_cache = LruCache::new(cache_capacity);
More information about the pbs-devel
mailing list