public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Christian Ebner <c.ebner@proxmox.com>
Subject: Re: [pbs-devel] [RFC proxmox-backup 2/4] datastore: allow to specify sub-directory for index file listing
Date: Fri, 18 Apr 2025 11:38:52 +0200	[thread overview]
Message-ID: <eed9fae8-c923-4e24-aefa-08d700c4070e@proxmox.com> (raw)
In-Reply-To: <20250416141803.479125-3-c.ebner@proxmox.com>

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@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);



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  reply	other threads:[~2025-04-18  9:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 14:17 [pbs-devel] [RFC proxmox-backup 0/4] implement trash can for snapshots Christian Ebner
2025-04-16 14:18 ` [pbs-devel] [RFC proxmox-backup 1/4] datastore: always skip over base directory when listing index files Christian Ebner
2025-04-17  9:29   ` Fabian Grünbichler
2025-04-17 10:27     ` Christian Ebner
2025-04-16 14:18 ` [pbs-devel] [RFC proxmox-backup 2/4] datastore: allow to specify sub-directory for index file listing Christian Ebner
2025-04-18  9:38   ` Thomas Lamprecht [this message]
2025-04-18  9:55     ` Christian Ebner
2025-04-16 14:18 ` [pbs-devel] [RFC proxmox-backup 3/4] datastore: move snapshots to trash folder on destroy Christian Ebner
2025-04-17  9:29   ` Fabian Grünbichler
2025-04-18 11:06     ` Thomas Lamprecht
2025-04-18 11:49       ` Christian Ebner
2025-04-18 12:03         ` Fabian Grünbichler
2025-04-18 12:45           ` Christian Ebner
2025-04-22  7:54             ` Fabian Grünbichler
2025-04-29 11:27               ` Christian Ebner
2025-04-18 11:51       ` Fabian Grünbichler
2025-04-16 14:18 ` [pbs-devel] [RFC proxmox-backup 4/4] garbage collection: read pruned snapshot index files from trash Christian Ebner
2025-04-17  9:29   ` Fabian Grünbichler
2025-04-17 10:38     ` Christian Ebner
2025-04-17 11:27       ` Fabian Grünbichler
2025-04-17  9:29 ` [pbs-devel] [RFC proxmox-backup 0/4] implement trash can for snapshots Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eed9fae8-c923-4e24-aefa-08d700c4070e@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal