Showing the changes to gitoxide-core/src (1 of 8 files). Show all
Unified · Split
| @@ -74,7 +74,7 @@ pub fn create( · 73 unmodified lines | |||
| 74 | repository: impl AsRef<Path>, | 74 | repository: impl AsRef<Path>, |
| 75 | tips: impl IntoIterator<Item = impl AsRef<OsStr>>, | 75 | tips: impl IntoIterator<Item = impl AsRef<OsStr>>, |
| 76 | input: Option<impl io::BufRead + Send + 'static>, | 76 | input: Option<impl io::BufRead + Send + 'static>, |
| 77 | out: impl io::Write, | 77 | output_directory: impl AsRef<Path>, |
| 78 | mut progress: impl Progress, | 78 | mut progress: impl Progress, |
| 79 | ctx: Context, | 79 | ctx: Context, |
| 80 | ) -> anyhow::Result<()> { | 80 | ) -> anyhow::Result<()> { |
| @@ -154,25 +154,27 @@ pub fn create( · 73 unmodified lines | |||
| 154 | write_progress.init(None, progress::bytes()); | 154 | write_progress.init(None, progress::bytes()); |
| 155 | let start = Instant::now(); | 155 | let start = Instant::now(); |
| 156 | 156 | ||
| 157 | let mut pack_file = tempfile::NamedTempFile::new_in(&output_directory)?; | ||
| 157 | let mut output_iter = pack::data::output::bytes::FromEntriesIter::new( | 158 | let mut output_iter = pack::data::output::bytes::FromEntriesIter::new( |
| 158 | entries.inspect(|e| { | 159 | entries.inspect(|e| { |
| 159 | if let Ok(entries) = e { | 160 | if let Ok(entries) = e { |
| 160 | entries_progress.inc_by(entries.len()) | 161 | entries_progress.inc_by(entries.len()) |
| 161 | } | 162 | } |
| 162 | }), | 163 | }), |
| 163 | out, | 164 | &mut pack_file, |
| 164 | num_objects as u32, | 165 | num_objects as u32, |
| 165 | pack::data::Version::default(), | 166 | pack::data::Version::default(), |
| 166 | hash::Kind::default(), | 167 | hash::Kind::default(), |
| 167 | ); | 168 | ); |
| 168 | while let Some(io_res) = output_iter.next() { | 169 | for io_res in output_iter.by_ref() { |
| 169 | if interrupt::is_triggered() { | 170 | if interrupt::is_triggered() { |
| 170 | bail!("Cancelled by user") | 171 | bail!("Cancelled by user") |
| 171 | } | 172 | } |
| 172 | let written = io_res?; | 173 | let written = io_res?; |
| 173 | write_progress.inc_by(written as usize); | 174 | write_progress.inc_by(written as usize); |
| 174 | } | 175 | } |
| 175 | output_iter.into_write().flush()?; | 176 | let hash = output_iter.digest().expect("iteration is done"); |
| 177 | pack_file.persist(output_directory.as_ref().join(format!("{}.pack", hash)))?; | ||
| 176 | 178 | ||
| 177 | write_progress.show_throughput(start); | 179 | write_progress.show_throughput(start); |
| 178 | entries_progress.show_throughput(start); | 180 | entries_progress.show_throughput(start); |