tape: media_catalog: improve chunk_archive interface
instead of having a public start/end_chunk_archive and register_chunks, simply expose a 'register_chunk_archive' method since we always have a list of chunks anywhere we want to add them Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
9a1ecae0b7
commit
a2ef36d445
|
@ -1121,16 +1121,13 @@ fn restore_archive<'a>(
|
|||
};
|
||||
|
||||
if let Some(chunks) = chunks {
|
||||
catalog.start_chunk_archive(
|
||||
catalog.register_chunk_archive(
|
||||
Uuid::from(header.uuid),
|
||||
current_file_number,
|
||||
&source_datastore,
|
||||
&chunks[..],
|
||||
)?;
|
||||
for digest in chunks.iter() {
|
||||
catalog.register_chunk(&digest)?;
|
||||
}
|
||||
task_log!(worker, "register {} chunks", chunks.len());
|
||||
catalog.end_chunk_archive()?;
|
||||
catalog.commit_if_large()?;
|
||||
}
|
||||
return Ok(());
|
||||
|
|
|
@ -503,10 +503,26 @@ impl MediaCatalog {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Register a chunk archive
|
||||
pub fn register_chunk_archive(
|
||||
&mut self,
|
||||
uuid: Uuid, // Uuid form MediaContentHeader
|
||||
file_number: u64,
|
||||
store: &str,
|
||||
chunk_list: &[[u8; 32]],
|
||||
) -> Result<(), Error> {
|
||||
self.start_chunk_archive(uuid, file_number, store)?;
|
||||
for digest in chunk_list {
|
||||
self.register_chunk(digest)?;
|
||||
}
|
||||
self.end_chunk_archive()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Register a chunk
|
||||
///
|
||||
/// Only valid after start_chunk_archive.
|
||||
pub fn register_chunk(
|
||||
fn register_chunk(
|
||||
&mut self,
|
||||
digest: &[u8;32],
|
||||
) -> Result<(), Error> {
|
||||
|
@ -557,7 +573,7 @@ impl MediaCatalog {
|
|||
}
|
||||
|
||||
/// Start a chunk archive section
|
||||
pub fn start_chunk_archive(
|
||||
fn start_chunk_archive(
|
||||
&mut self,
|
||||
uuid: Uuid, // Uuid form MediaContentHeader
|
||||
file_number: u64,
|
||||
|
@ -606,7 +622,7 @@ impl MediaCatalog {
|
|||
}
|
||||
|
||||
/// End a chunk archive section
|
||||
pub fn end_chunk_archive(&mut self) -> Result<(), Error> {
|
||||
fn end_chunk_archive(&mut self) -> Result<(), Error> {
|
||||
|
||||
match self.current_archive.take() {
|
||||
None => bail!("end_chunk_archive failed: not started"),
|
||||
|
|
|
@ -97,11 +97,7 @@ impl CatalogSet {
|
|||
) -> Result<(), Error> {
|
||||
match self.catalog {
|
||||
Some(ref mut catalog) => {
|
||||
catalog.start_chunk_archive(uuid, file_number, store)?;
|
||||
for digest in chunk_list {
|
||||
catalog.register_chunk(digest)?;
|
||||
}
|
||||
catalog.end_chunk_archive()?;
|
||||
catalog.register_chunk_archive(uuid, file_number, store, chunk_list)?;
|
||||
}
|
||||
None => bail!("no catalog loaded - internal error"),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue