Skip to content

Commit a03bde5

Browse files
committed
fix: write_blob_stream() does not need Seek trait anymore.
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.
1 parent 304eb74 commit a03bde5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

gix/src/repository/object.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,10 @@ impl crate::Repository {
205205
/// we avoid writing duplicate objects using slow disks that will eventually have to be garbage collected.
206206
///
207207
/// If that is prohibitive, use the object database directly.
208-
pub fn write_blob_stream(
209-
&self,
210-
mut bytes: impl std::io::Read + std::io::Seek,
211-
) -> Result<Id<'_>, object::write::Error> {
208+
pub fn write_blob_stream(&self, mut bytes: impl std::io::Read) -> Result<Id<'_>, object::write::Error> {
212209
let mut buf = self.empty_reusable_buffer();
213-
std::io::copy(&mut bytes, buf.deref_mut()).expect("write to memory works");
210+
std::io::copy(&mut bytes, buf.deref_mut())
211+
.map_err(|err| Box::new(err) as Box<dyn std::error::Error + Send + Sync>)?;
214212

215213
self.write_blob_stream_inner(&buf)
216214
}

0 commit comments

Comments
 (0)