From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/3] api2: tape: media: use MediaCatalog::snapshot_list for content listing
Date: Mon, 19 Jul 2021 16:55:56 +0200 [thread overview]
Message-ID: <20210719145556.2781356-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210719145556.2781356-1-d.csapak@proxmox.com>
this should make the api call much faster, since it is not reading
the whole catalog anymore
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/tape/media.rs | 44 +++++++++++++++++++-----------------------
1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/src/api2/tape/media.rs b/src/api2/tape/media.rs
index 8351b2be..cc2d896d 100644
--- a/src/api2/tape/media.rs
+++ b/src/api2/tape/media.rs
@@ -502,32 +502,28 @@ pub fn list_content(
.generate_media_set_name(&set.uuid, template)
.unwrap_or_else(|_| set.uuid.to_string());
- let catalog = MediaCatalog::open(status_path, &media_id, false, false)?;
+ for (store, snapshot) in MediaCatalog::snapshot_list(status_path, &media_id)? {
+ let backup_dir: BackupDir = snapshot.parse()?;
- for (store, content) in catalog.content() {
- for snapshot in content.snapshot_index.keys() {
- let backup_dir: BackupDir = snapshot.parse()?;
-
- if let Some(ref backup_type) = filter.backup_type {
- if backup_dir.group().backup_type() != backup_type { continue; }
- }
- if let Some(ref backup_id) = filter.backup_id {
- if backup_dir.group().backup_id() != backup_id { continue; }
- }
-
- list.push(MediaContentEntry {
- uuid: media_id.label.uuid.clone(),
- label_text: media_id.label.label_text.to_string(),
- pool: set.pool.clone(),
- media_set_name: media_set_name.clone(),
- media_set_uuid: set.uuid.clone(),
- media_set_ctime: set.ctime,
- seq_nr: set.seq_nr,
- snapshot: snapshot.to_owned(),
- store: store.to_owned(),
- backup_time: backup_dir.backup_time(),
- });
+ if let Some(ref backup_type) = filter.backup_type {
+ if backup_dir.group().backup_type() != backup_type { continue; }
+ }
+ if let Some(ref backup_id) = filter.backup_id {
+ if backup_dir.group().backup_id() != backup_id { continue; }
}
+
+ list.push(MediaContentEntry {
+ uuid: media_id.label.uuid.clone(),
+ label_text: media_id.label.label_text.to_string(),
+ pool: set.pool.clone(),
+ media_set_name: media_set_name.clone(),
+ media_set_uuid: set.uuid.clone(),
+ media_set_ctime: set.ctime,
+ seq_nr: set.seq_nr,
+ snapshot: snapshot.to_owned(),
+ store: store.to_owned(),
+ backup_time: backup_dir.backup_time(),
+ });
}
}
--
2.30.2
prev parent reply other threads:[~2021-07-19 14:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 14:55 [pbs-devel] [PATCH proxmox-backup 1/3] tape: media_catalog: add fast_catalog beside normal catalog Dominik Csapak
2021-07-19 14:55 ` [pbs-devel] [RFC PATCH proxmox-backup 2/3] tape: media_catalog: add local type aliases to make code more clear Dominik Csapak
2021-07-19 14:55 ` Dominik Csapak [this message]
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=20210719145556.2781356-3-d.csapak@proxmox.com \
--to=d.csapak@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