public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/4] remove BackupGroup::list_groups
Date: Mon, 30 Nov 2020 16:27:18 +0100	[thread overview]
Message-ID: <20201130152721.666511-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20201130152721.666511-1-f.gruenbichler@proxmox.com>

BackupInfo::list_backup_groups is identical code-wise, and makes more
sense as entry point for listing groups.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    we could of course remove the other one, or move this to datastore.rs altogether?

 src/backup/backup_info.rs | 14 --------------
 src/backup/verify.rs      |  2 +-
 src/client/pull.rs        |  2 +-
 src/server/prune_job.rs   |  4 ++--
 4 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/src/backup/backup_info.rs b/src/backup/backup_info.rs
index 367cb8ee..5ff1a6f8 100644
--- a/src/backup/backup_info.rs
+++ b/src/backup/backup_info.rs
@@ -145,20 +145,6 @@ impl BackupGroup {
 
         Ok(last)
     }
-
-    pub fn list_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
-        let mut list = Vec::new();
-
-        tools::scandir(libc::AT_FDCWD, base_path, &BACKUP_TYPE_REGEX, |l0_fd, backup_type, file_type| {
-            if file_type != nix::dir::Type::Directory { return Ok(()); }
-            tools::scandir(l0_fd, backup_type, &BACKUP_ID_REGEX, |_l1_fd, backup_id, file_type| {
-                if file_type != nix::dir::Type::Directory { return Ok(()); }
-                list.push(BackupGroup::new(backup_type, backup_id));
-                Ok(())
-            })
-        })?;
-        Ok(list)
-    }
 }
 
 impl std::fmt::Display for BackupGroup {
diff --git a/src/backup/verify.rs b/src/backup/verify.rs
index 1eccdd67..21a31a3f 100644
--- a/src/backup/verify.rs
+++ b/src/backup/verify.rs
@@ -533,7 +533,7 @@ pub fn verify_all_backups(
         }
     };
 
-    let mut list = match BackupGroup::list_groups(&datastore.base_path()) {
+    let mut list = match BackupInfo::list_backup_groups(&datastore.base_path()) {
         Ok(list) => list
             .into_iter()
             .filter(|group| !(group.backup_type() == "host" && group.backup_id() == "benchmark"))
diff --git a/src/client/pull.rs b/src/client/pull.rs
index 7d55f9fa..0c9afe0a 100644
--- a/src/client/pull.rs
+++ b/src/client/pull.rs
@@ -565,7 +565,7 @@ pub async fn pull_store(
 
     if delete {
         let result: Result<(), Error> = proxmox::try_block!({
-            let local_groups = BackupGroup::list_groups(&tgt_store.base_path())?;
+            let local_groups = BackupInfo::list_backup_groups(&tgt_store.base_path())?;
             for local_group in local_groups {
                 if new_groups.contains(&local_group) { continue; }
                 worker.log(format!("delete vanished group '{}/{}'", local_group.backup_type(), local_group.backup_id()));
diff --git a/src/server/prune_job.rs b/src/server/prune_job.rs
index 67d438d9..572f1b04 100644
--- a/src/server/prune_job.rs
+++ b/src/server/prune_job.rs
@@ -4,7 +4,7 @@ use proxmox::try_block;
 
 use crate::{
     api2::types::*,
-    backup::{compute_prune_info, BackupGroup, DataStore, PruneOptions},
+    backup::{compute_prune_info, BackupInfo, DataStore, PruneOptions},
     server::jobstate::Job,
     server::WorkerTask,
     task_log,
@@ -43,7 +43,7 @@ pub fn do_prune_job(
 
                 let base_path = datastore.base_path();
 
-                let groups = BackupGroup::list_groups(&base_path)?;
+                let groups = BackupInfo::list_backup_groups(&base_path)?;
                 for group in groups {
                     let list = group.list_backups(&base_path)?;
                     let mut prune_info = compute_prune_info(list, &prune_options)?;
-- 
2.20.1





  reply	other threads:[~2020-11-30 15:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 15:27 [pbs-devel] [PATCH proxmox-backup 0/4] pull/verify unified progress Fabian Grünbichler
2020-11-30 15:27 ` Fabian Grünbichler [this message]
2020-11-30 15:27 ` [pbs-devel] [PATCH proxmox-backup 2/4] pull: factor out interpolated progress Fabian Grünbichler
2020-12-01  5:21   ` Dietmar Maurer
2020-11-30 15:27 ` [pbs-devel] [PATCH proxmox-backup 3/4] progress: add format variants Fabian Grünbichler
2020-11-30 15:27 ` [pbs-devel] [PATCH proxmox-backup 4/4] verify: use same progress as pull Fabian Grünbichler
2020-12-01  5:40 ` [pbs-devel] applied: [PATCH proxmox-backup 0/4] pull/verify unified progress Dietmar Maurer

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=20201130152721.666511-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@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