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