From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/4] progress: add format variants
Date: Mon, 30 Nov 2020 16:27:20 +0100 [thread overview]
Message-ID: <20201130152721.666511-4-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20201130152721.666511-1-f.gruenbichler@proxmox.com>
for iterating over a single group, or iterating just on the group level
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
src/backup/datastore.rs | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs
index 4f49d03f..20617d38 100644
--- a/src/backup/datastore.rs
+++ b/src/backup/datastore.rs
@@ -775,14 +775,32 @@ impl StoreProgress {
impl std::fmt::Display for StoreProgress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(
- f,
- "{:.2}% ({} of {} groups, {} of {} group snapshots)",
- self.percentage() * 100.0,
- self.done_groups,
- self.total_groups,
- self.done_snapshots,
- self.group_snapshots,
- )
+ if self.group_snapshots == 0 {
+ write!(
+ f,
+ "{:.2}% ({} of {} groups)",
+ self.percentage() * 100.0,
+ self.done_groups,
+ self.total_groups,
+ )
+ } else if self.total_groups == 1 {
+ write!(
+ f,
+ "{:.2}% ({} of {} snapshots)",
+ self.percentage() * 100.0,
+ self.done_snapshots,
+ self.group_snapshots,
+ )
+ } else {
+ write!(
+ f,
+ "{:.2}% ({} of {} groups, {} of {} group snapshots)",
+ self.percentage() * 100.0,
+ self.done_groups,
+ self.total_groups,
+ self.done_snapshots,
+ self.group_snapshots,
+ )
+ }
}
}
--
2.20.1
next prev parent 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 ` [pbs-devel] [PATCH proxmox-backup 1/4] remove BackupGroup::list_groups Fabian Grünbichler
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 ` Fabian Grünbichler [this message]
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-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.