diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix-index/src/file/write.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-index/src/file/write.rs')
-rw-r--r-- | vendor/gix-index/src/file/write.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/vendor/gix-index/src/file/write.rs b/vendor/gix-index/src/file/write.rs index 1e8afc07d..47a4cde96 100644 --- a/vendor/gix-index/src/file/write.rs +++ b/vendor/gix-index/src/file/write.rs @@ -22,23 +22,28 @@ impl File { mut out: impl std::io::Write, options: write::Options, ) -> std::io::Result<(Version, gix_hash::ObjectId)> { - let mut hasher = hash::Write::new(&mut out, self.state.object_hash); - let version = self.state.write_to(&mut hasher, options)?; - - let hash = hasher.hash.digest(); - out.write_all(&hash)?; - Ok((version, gix_hash::ObjectId::from(hash))) + let (version, hash) = if options.skip_hash { + let out: &mut dyn std::io::Write = &mut out; + let version = self.state.write_to(out, options)?; + (version, self.state.object_hash.null()) + } else { + let mut hasher = hash::Write::new(&mut out, self.state.object_hash); + let out: &mut dyn std::io::Write = &mut hasher; + let version = self.state.write_to(out, options)?; + (version, gix_hash::ObjectId::from(hasher.hash.digest())) + }; + out.write_all(hash.as_slice())?; + Ok((version, hash)) } /// Write ourselves to the path we were read from after acquiring a lock, using `options`. /// /// Note that the hash produced will be stored which is why we need to be mutable. pub fn write(&mut self, options: write::Options) -> Result<(), Error> { - let mut lock = std::io::BufWriter::new(gix_lock::File::acquire_to_update_resource( - &self.path, - gix_lock::acquire::Fail::Immediately, - None, - )?); + let mut lock = std::io::BufWriter::with_capacity( + 64 * 1024, + gix_lock::File::acquire_to_update_resource(&self.path, gix_lock::acquire::Fail::Immediately, None)?, + ); let (version, digest) = self.write_to(&mut lock, options)?; match lock.into_inner() { Ok(lock) => lock.commit()?, |