tape/media_catalog: add helpers to look for snapshot/chunk files

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-05-05 12:09:12 +02:00 committed by Dietmar Maurer
parent 56d36ca439
commit 2e41dbe828

View File

@ -924,6 +924,16 @@ impl MediaSetCatalog {
false false
} }
/// Returns the media uuid and snapshot archive file number
pub fn lookup_snapshot(&self, store: &str, snapshot: &str) -> Option<(&Uuid, u64)> {
for (uuid, catalog) in self.catalog_list.iter() {
if let Some(nr) = catalog.lookup_snapshot(store, snapshot) {
return Some((uuid, nr));
}
}
None
}
/// Test if the catalog already contain a chunk /// Test if the catalog already contain a chunk
pub fn contains_chunk(&self, store: &str, digest: &[u8;32]) -> bool { pub fn contains_chunk(&self, store: &str, digest: &[u8;32]) -> bool {
for catalog in self.catalog_list.values() { for catalog in self.catalog_list.values() {
@ -933,6 +943,16 @@ impl MediaSetCatalog {
} }
false false
} }
/// Returns the media uuid and chunk archive file number
pub fn lookup_chunk(&self, store: &str, digest: &[u8;32]) -> Option<(&Uuid, u64)> {
for (uuid, catalog) in self.catalog_list.iter() {
if let Some(nr) = catalog.lookup_chunk(store, digest) {
return Some((uuid, nr));
}
}
None
}
} }
// Type definitions for internal binary catalog encoding // Type definitions for internal binary catalog encoding