diff options
Diffstat (limited to 'vendor/gix-odb/src/store_impls/loose')
-rw-r--r-- | vendor/gix-odb/src/store_impls/loose/find.rs | 18 | ||||
-rw-r--r-- | vendor/gix-odb/src/store_impls/loose/verify.rs | 8 | ||||
-rw-r--r-- | vendor/gix-odb/src/store_impls/loose/write.rs | 36 |
3 files changed, 31 insertions, 31 deletions
diff --git a/vendor/gix-odb/src/store_impls/loose/find.rs b/vendor/gix-odb/src/store_impls/loose/find.rs index 04fabe61b..91bf0ba87 100644 --- a/vendor/gix-odb/src/store_impls/loose/find.rs +++ b/vendor/gix-odb/src/store_impls/loose/find.rs @@ -34,9 +34,9 @@ impl Store { const OPEN_ACTION: &'static str = "open"; /// Returns true if the given id is contained in our repository. - pub fn contains(&self, id: impl AsRef<gix_hash::oid>) -> bool { - debug_assert_eq!(self.object_hash, id.as_ref().kind()); - hash_path(id.as_ref(), self.path.clone()).is_file() + pub fn contains(&self, id: &gix_hash::oid) -> bool { + debug_assert_eq!(self.object_hash, id.kind()); + hash_path(id, self.path.clone()).is_file() } /// Given a `prefix`, find an object that matches it uniquely within this loose object @@ -56,7 +56,7 @@ impl Store { ) -> Result<Option<crate::store::prefix::lookup::Outcome>, crate::loose::iter::Error> { let single_directory_iter = crate::loose::Iter { inner: gix_features::fs::walkdir_new( - self.path.join(prefix.as_oid().to_hex_with_len(2).to_string()), + &self.path.join(prefix.as_oid().to_hex_with_len(2).to_string()), gix_features::fs::walkdir::Parallelism::Serial, ) .min_depth(1) @@ -108,11 +108,11 @@ impl Store { /// there was no such object. pub fn try_find<'a>( &self, - id: impl AsRef<gix_hash::oid>, + id: &gix_hash::oid, out: &'a mut Vec<u8>, ) -> Result<Option<gix_object::Data<'a>>, Error> { - debug_assert_eq!(self.object_hash, id.as_ref().kind()); - match self.find_inner(id.as_ref(), out) { + debug_assert_eq!(self.object_hash, id.kind()); + match self.find_inner(id, out) { Ok(obj) => Ok(Some(obj)), Err(err) => match err { Error::Io { @@ -137,10 +137,10 @@ impl Store { /// Return only the decompressed size of the object and its kind without fully reading it into memory as tuple of `(size, kind)`. /// Returns `None` if `id` does not exist in the database. - pub fn try_header(&self, id: impl AsRef<gix_hash::oid>) -> Result<Option<(usize, gix_object::Kind)>, Error> { + pub fn try_header(&self, id: &gix_hash::oid) -> Result<Option<(usize, gix_object::Kind)>, Error> { const BUF_SIZE: usize = 256; let mut buf = [0_u8; BUF_SIZE]; - let path = hash_path(id.as_ref(), self.path.clone()); + let path = hash_path(id, self.path.clone()); let mut inflate = zlib::Inflate::default(); let mut istream = match fs::File::open(&path) { diff --git a/vendor/gix-odb/src/store_impls/loose/verify.rs b/vendor/gix-odb/src/store_impls/loose/verify.rs index 8ffbb7105..ae83c1d01 100644 --- a/vendor/gix-odb/src/store_impls/loose/verify.rs +++ b/vendor/gix-odb/src/store_impls/loose/verify.rs @@ -3,7 +3,7 @@ use std::{ time::Instant, }; -use gix_features::progress::Progress; +use gix_features::progress::{Count, DynNestedProgress, Progress}; use crate::{loose::Store, Write}; @@ -61,7 +61,7 @@ impl Store { /// Check all loose objects for their integrity checking their hash matches the actual data and by decoding them fully. pub fn verify_integrity( &self, - mut progress: impl Progress, + progress: &mut dyn DynNestedProgress, should_interrupt: &AtomicBool, ) -> Result<integrity::Statistics, integrity::Error> { let mut buf = Vec::new(); @@ -69,11 +69,11 @@ impl Store { let mut num_objects = 0; let start = Instant::now(); - let mut progress = progress.add_child_with_id("Validating", integrity::ProgressId::LooseObjects.into()); + let mut progress = progress.add_child_with_id("Validating".into(), integrity::ProgressId::LooseObjects.into()); progress.init(None, gix_features::progress::count("loose objects")); for id in self.iter().filter_map(Result::ok) { let object = self - .try_find(id, &mut buf) + .try_find(&id, &mut buf) .map_err(|_| integrity::Error::Retry)? .ok_or(integrity::Error::Retry)?; let actual_id = sink.write_buf(object.kind, object.data).expect("sink never fails"); diff --git a/vendor/gix-odb/src/store_impls/loose/write.rs b/vendor/gix-odb/src/store_impls/loose/write.rs index 912426bba..e537eda92 100644 --- a/vendor/gix-odb/src/store_impls/loose/write.rs +++ b/vendor/gix-odb/src/store_impls/loose/write.rs @@ -27,9 +27,7 @@ pub enum Error { } impl crate::traits::Write for Store { - type Error = Error; - - fn write(&self, object: impl WriteTo) -> Result<gix_hash::ObjectId, Self::Error> { + fn write(&self, object: &dyn WriteTo) -> Result<gix_hash::ObjectId, crate::write::Error> { let mut to = self.dest()?; to.write_all(&object.loose_header()).map_err(|err| Error::Io { source: err, @@ -41,15 +39,15 @@ impl crate::traits::Write for Store { message: "stream all data into tempfile in", path: self.path.to_owned(), })?; - to.flush()?; - self.finalize_object(to) + to.flush().map_err(Box::new)?; + Ok(self.finalize_object(to).map_err(Box::new)?) } /// Write the given buffer in `from` to disk in one syscall at best. /// /// This will cost at least 4 IO operations. - fn write_buf(&self, kind: gix_object::Kind, from: &[u8]) -> Result<gix_hash::ObjectId, Self::Error> { - let mut to = self.dest()?; + fn write_buf(&self, kind: gix_object::Kind, from: &[u8]) -> Result<gix_hash::ObjectId, crate::write::Error> { + let mut to = self.dest().map_err(Box::new)?; to.write_all(&gix_object::encode::loose_header(kind, from.len())) .map_err(|err| Error::Io { source: err, @@ -63,7 +61,7 @@ impl crate::traits::Write for Store { path: self.path.to_owned(), })?; to.flush()?; - self.finalize_object(to) + Ok(self.finalize_object(to)?) } /// Write the given stream in `from` to disk with at least one syscall. @@ -73,9 +71,9 @@ impl crate::traits::Write for Store { &self, kind: gix_object::Kind, size: u64, - mut from: impl io::Read, - ) -> Result<gix_hash::ObjectId, Self::Error> { - let mut to = self.dest()?; + mut from: &mut dyn io::Read, + ) -> Result<gix_hash::ObjectId, crate::write::Error> { + let mut to = self.dest().map_err(Box::new)?; to.write_all(&gix_object::encode::loose_header( kind, size.try_into().expect("object size to fit into usize"), @@ -86,13 +84,15 @@ impl crate::traits::Write for Store { path: self.path.to_owned(), })?; - io::copy(&mut from, &mut to).map_err(|err| Error::Io { - source: err, - message: "stream all data into tempfile in", - path: self.path.to_owned(), - })?; - to.flush()?; - self.finalize_object(to) + io::copy(&mut from, &mut to) + .map_err(|err| Error::Io { + source: err, + message: "stream all data into tempfile in", + path: self.path.to_owned(), + }) + .map_err(Box::new)?; + to.flush().map_err(Box::new)?; + Ok(self.finalize_object(to)?) } } |