Skip to content

Commit

Permalink
fix: write_blob_stream() does not need Seek trait anymore.
Browse files Browse the repository at this point in the history
Internally, it has to turn it into a buffer so it's not needed anymore.
It also counteracts the idea of using a stream with arbitrarily big files.
  • Loading branch information
Byron committed Jan 4, 2025
1 parent 08a87de commit 9c8d9e4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions gix/src/repository/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,10 @@ impl crate::Repository {
/// we avoid writing duplicate objects using slow disks that will eventually have to be garbage collected.
///
/// If that is prohibitive, use the object database directly.
pub fn write_blob_stream(
&self,
mut bytes: impl std::io::Read + std::io::Seek,
) -> Result<Id<'_>, object::write::Error> {
pub fn write_blob_stream(&self, mut bytes: impl std::io::Read) -> Result<Id<'_>, object::write::Error> {
let mut buf = self.empty_reusable_buffer();
std::io::copy(&mut bytes, buf.deref_mut()).expect("write to memory works");
std::io::copy(&mut bytes, buf.deref_mut())
.map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync>)?;

self.write_blob_stream_inner(&buf)
}
Expand Down

0 comments on commit 9c8d9e4

Please sign in to comment.