Skip to content

Commit

Permalink
The very first version of complete pack writing (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Apr 25, 2021
1 parent 722202e commit 4d76d53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion git-odb/src/pack/data/encode/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ where
written += std::io::copy(&mut &*entry.compressed_data, &mut self.output)? as u64;
}
}
None => todo!("write footer and set is_done = true"),
None => {
let digest = self.output.hash.clone().digest();
self.output.write_all(&digest[..])?;
written += digest.len() as u64;
self.output.flush()?;
self.is_done = true;
}
};
Ok(written)
}
Expand Down
5 changes: 3 additions & 2 deletions git-odb/tests/odb/pack/data/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ mod entries {
}

#[test]
#[should_panic]
fn all_input_objects() {
(|| -> crate::Result {
let db = db(DbKind::AbunchOfRandomObjects)?;
Expand Down Expand Up @@ -48,7 +47,8 @@ mod entries {
pack::data::Version::V2,
git_hash::Kind::Sha1,
);
let n = pack_writer.next().expect("one entries bundle was written")?;
let mut n = pack_writer.next().expect("one entries bundle was written")?;
n += pack_writer.next().expect("the trailer was written")?;
assert!(
pack_writer.next().is_none(),
"there is nothing more to iterate this time"
Expand All @@ -63,6 +63,7 @@ mod entries {
pack_file.metadata()?.len(),
"it reports the correct amount of written bytes"
);
// TODO: verify the new pack

Ok(())
})()
Expand Down

0 comments on commit 4d76d53

Please sign in to comment.