History

[pack] write packs to a directory with the proper name

Sebastian Thiel committed 5 years ago

Commit 3fbca7d1 parent f10adea8 files · +31 −25Browse files

Showing the changes to git-pack/src/data (1 of 8 files). Show all

Unified · Split

git-pack/src/data/output/bytes.rs+10−0
@@ -22,6 +22,8 @@ pub struct FromEntriesIter<I, W> { · 21 unmodified lines
2222 pub input: I,
2323 /// A way of writing encoded bytes.
2424 output: hash::Write<W>,
25+ /// Our trailing hash when done writing all input entries
26+ trailer: Option<git_hash::ObjectId>,
2527 /// The amount of objects in the iteration and the version of the packfile to be written.
2628 /// Will be `None` to signal the header was written already.
2729 header_info: Option<(crate::data::Version, u32)>,
@@ -62,6 +64,7 @@ where · 34 unmodified lines
6264 FromEntriesIter {
6365 input,
6466 output: hash::Write::new(output, hash_kind),
67+ trailer: None,
6568 entry_version: version,
6669 header_info: Some((version, num_entries)),
6770 is_done: false,
@@ -75,6 +78,12 @@ where · 7 unmodified lines
7578 self.output.inner
7679 }
7780
81+ /// Returns the trailing hash over all written entries once done.
82+ /// It's `None` if we are not yet done writing.
83+ pub fn digest(&self) -> Option<git_hash::ObjectId> {
84+ self.trailer.clone()
85+ }
86+
7887 fn next_inner(&mut self) -> Result<u64, Error<E>> {
7988 let mut written = 0u64;
8089 if let Some((version, num_entries)) = self.header_info.take() {
@@ -98,6 +107,7 @@ where · 17 unmodified lines
98107 written += digest.len() as u64;
99108 self.output.flush()?;
100109 self.is_done = true;
110+ self.trailer = Some(git_hash::ObjectId::from(digest));
101111 }
102112 };
103113 Ok(written)