Showing the changes to git-pack/src (1 of 8 files). Show all
Unified · Split
| @@ -22,6 +22,8 @@ pub struct FromEntriesIter<I, W> { · 21 unmodified lines | ||
| 22 | 22 | pub input: I, |
| 23 | 23 | /// A way of writing encoded bytes. |
| 24 | 24 | output: hash::Write<W>, |
| 25 | + /// Our trailing hash when done writing all input entries | |
| 26 | + trailer: Option<git_hash::ObjectId>, | |
| 25 | 27 | /// The amount of objects in the iteration and the version of the packfile to be written. |
| 26 | 28 | /// Will be `None` to signal the header was written already. |
| 27 | 29 | header_info: Option<(crate::data::Version, u32)>, |
| @@ -62,6 +64,7 @@ where · 34 unmodified lines | ||
| 62 | 64 | FromEntriesIter { |
| 63 | 65 | input, |
| 64 | 66 | output: hash::Write::new(output, hash_kind), |
| 67 | + trailer: None, | |
| 65 | 68 | entry_version: version, |
| 66 | 69 | header_info: Some((version, num_entries)), |
| 67 | 70 | is_done: false, |
| @@ -75,6 +78,12 @@ where · 7 unmodified lines | ||
| 75 | 78 | self.output.inner |
| 76 | 79 | } |
| 77 | 80 | |
| 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 | + | |
| 78 | 87 | fn next_inner(&mut self) -> Result<u64, Error<E>> { |
| 79 | 88 | let mut written = 0u64; |
| 80 | 89 | if let Some((version, num_entries)) = self.header_info.take() { |
| @@ -98,6 +107,7 @@ where · 17 unmodified lines | ||
| 98 | 107 | written += digest.len() as u64; |
| 99 | 108 | self.output.flush()?; |
| 100 | 109 | self.is_done = true; |
| 110 | + self.trailer = Some(git_hash::ObjectId::from(digest)); | |
| 101 | 111 | } |
| 102 | 112 | }; |
| 103 | 113 | Ok(written) |