[pbs-devel] [PATCH v3 proxmox-backup 2/5] backup debug: diff: refactor backup reader creation
Christian Ebner
c.ebner at proxmox.com
Thu Jan 9 15:06:20 CET 2025
Move the backup reader instantiation code out of the corresponding
helper function to its only call side. In preparation for adding the
backup reader finish api call on termination. By moving this code,
the backup reader can be handled more easily.
No functional change intended.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 2:
- not present in previous version
src/bin/proxmox_backup_debug/diff.rs | 40 +++++++++++-----------------
1 file changed, 16 insertions(+), 24 deletions(-)
diff --git a/src/bin/proxmox_backup_debug/diff.rs b/src/bin/proxmox_backup_debug/diff.rs
index 02389d0e5..fc65f3120 100644
--- a/src/bin/proxmox_backup_debug/diff.rs
+++ b/src/bin/proxmox_backup_debug/diff.rs
@@ -249,7 +249,22 @@ async fn open_dynamic_index(
archive_name: &BackupArchiveName,
params: &RepoParams,
) -> Result<(DynamicIndexReader, Accessor), Error> {
- let backup_reader = create_backup_reader(snapshot, params).await?;
+ let backup_dir = match snapshot.parse::<BackupPart>()? {
+ BackupPart::Dir(dir) => dir,
+ BackupPart::Group(_group) => {
+ bail!("A full snapshot path must be provided.");
+ }
+ };
+ let client = connect(¶ms.repo)?;
+ let backup_reader = BackupReader::start(
+ &client,
+ params.crypt_config.clone(),
+ params.repo.store(),
+ ¶ms.namespace,
+ &backup_dir,
+ false,
+ )
+ .await?;
let (manifest, _) = backup_reader.download_manifest().await?;
manifest.check_fingerprint(params.crypt_config.as_ref().map(Arc::as_ref))?;
@@ -279,29 +294,6 @@ async fn open_dynamic_index(
Ok((lookup_index, accessor))
}
-async fn create_backup_reader(
- snapshot: &str,
- params: &RepoParams,
-) -> Result<Arc<BackupReader>, Error> {
- let backup_dir = match snapshot.parse::<BackupPart>()? {
- BackupPart::Dir(dir) => dir,
- BackupPart::Group(_group) => {
- bail!("A full snapshot path must be provided.");
- }
- };
- let client = connect(¶ms.repo)?;
- let backup_reader = BackupReader::start(
- &client,
- params.crypt_config.clone(),
- params.repo.store(),
- ¶ms.namespace,
- &backup_dir,
- false,
- )
- .await?;
- Ok(backup_reader)
-}
-
/// Get a list of chunk digests for an index file.
fn chunk_digests_for_index(index: &dyn IndexFile) -> Vec<&ChunkDigest> {
let mut all_chunks = Vec::new();
--
2.39.5
More information about the pbs-devel
mailing list