tape: write_chunk_archive - do not consume partially written chunk at EOT
So that it is re-written to the next tape.
This commit is contained in:
parent
355a41a763
commit
e8913fea12
@ -96,7 +96,6 @@ impl SnapshotReader {
|
|||||||
/// Note: The iterator returns a `Result`, and the iterator state is
|
/// Note: The iterator returns a `Result`, and the iterator state is
|
||||||
/// undefined after the first error. So it make no sense to continue
|
/// undefined after the first error. So it make no sense to continue
|
||||||
/// iteration after the first error.
|
/// iteration after the first error.
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct SnapshotChunkIterator<'a> {
|
pub struct SnapshotChunkIterator<'a> {
|
||||||
snapshot_reader: &'a SnapshotReader,
|
snapshot_reader: &'a SnapshotReader,
|
||||||
todo_list: Vec<String>,
|
todo_list: Vec<String>,
|
||||||
|
@ -418,14 +418,17 @@ fn write_chunk_archive<'a>(
|
|||||||
let mut leom = false;
|
let mut leom = false;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let digest = match chunk_iter.next() {
|
let digest = match chunk_iter.peek() {
|
||||||
None => break,
|
None => break,
|
||||||
Some(digest) => digest?,
|
Some(Ok(digest)) => *digest,
|
||||||
|
Some(Err(err)) => bail!("{}", err),
|
||||||
};
|
};
|
||||||
|
|
||||||
if media_catalog.contains_chunk(&digest)
|
if media_catalog.contains_chunk(&digest)
|
||||||
|| chunk_index.contains(&digest)
|
|| chunk_index.contains(&digest)
|
||||||
|| media_set_catalog.contains_chunk(&digest)
|
|| media_set_catalog.contains_chunk(&digest)
|
||||||
{
|
{
|
||||||
|
chunk_iter.next(); // consume
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,10 +437,12 @@ fn write_chunk_archive<'a>(
|
|||||||
|
|
||||||
match writer.try_write_chunk(&digest, &blob) {
|
match writer.try_write_chunk(&digest, &blob) {
|
||||||
Ok(true) => {
|
Ok(true) => {
|
||||||
|
chunk_iter.next(); // consume
|
||||||
chunk_index.insert(digest);
|
chunk_index.insert(digest);
|
||||||
chunk_list.push(digest);
|
chunk_list.push(digest);
|
||||||
}
|
}
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
|
// Note; we do not consume the chunk (no chunk_iter.next())
|
||||||
leom = true;
|
leom = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user