Unified · Split
| @@ -52,6 +52,8 @@ fn hash_path(id: &git_hash::oid, mut root: PathBuf) -> PathBuf { · 51 unmodified lines | ||
| 52 | 52 | pub mod find; |
| 53 | 53 | /// |
| 54 | 54 | pub mod iter; |
| 55 | +/// | |
| 56 | +pub mod verify; | |
| 55 | 57 | |
| 56 | 58 | /// The type for an iterator over `Result<git_hash::ObjectId, Error>)` |
| 57 | 59 | pub struct Iter { |
| @@ -0,0 +1,34 @@ | ||
| 1 | +#![allow(missing_docs)] | |
| 2 | +use crate::loose::Store; | |
| 3 | + | |
| 4 | +/// | |
| 5 | +pub mod integrity { | |
| 6 | + /// The error returned by [`verify_integrity()`][super::Store::verify_integrity()]. | |
| 7 | + #[derive(Debug, thiserror::Error)] | |
| 8 | + #[allow(missing_docs)] | |
| 9 | + pub enum Error { | |
| 10 | + #[error("{kind} object {id} could not be decoded")] | |
| 11 | + ObjectDecode { | |
| 12 | + source: git_object::decode::Error, | |
| 13 | + kind: git_object::Kind, | |
| 14 | + id: git_hash::ObjectId, | |
| 15 | + }, | |
| 16 | + #[error("{kind} object {expected} wasn't re-encoded without change - new hash is {actual}")] | |
| 17 | + ObjectEncodeMismatch { | |
| 18 | + kind: git_object::Kind, | |
| 19 | + actual: git_hash::ObjectId, | |
| 20 | + expected: git_hash::ObjectId, | |
| 21 | + }, | |
| 22 | + } | |
| 23 | + | |
| 24 | + pub struct Outcome { | |
| 25 | + /// The amount of loose objects we checked. | |
| 26 | + pub num_objects: usize, | |
| 27 | + } | |
| 28 | +} | |
| 29 | + | |
| 30 | +impl Store { | |
| 31 | + pub fn verify_integrity(&self) -> Result<integrity::Outcome, integrity::Error> { | |
| 32 | + todo!() | |
| 33 | + } | |
| 34 | +} | |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use git_odb::Write; |
| 2 | 2 | |
| 3 | −use crate::store::loose::backend::{locate_oid, object_ids}; | |
| 3 | +use crate::store::loose::{locate_oid, object_ids}; | |
| 4 | 4 | |
| 5 | 5 | #[test] |
| 6 | 6 | fn write() -> Result<(), Box<dyn std::error::Error>> { |
| @@ -1,3 +1,6 @@ | ||
| 1 | +use git_actor::{Sign, Time}; | |
| 2 | +use git_object::bstr::ByteSlice; | |
| 3 | + | |
| 1 | 4 | use git_odb::loose::Store; |
| 2 | 5 | use pretty_assertions::assert_eq; |
| 3 | 6 | |
| @@ -29,10 +32,18 @@ pub fn locate_oid(id: git_hash::ObjectId, buf: &mut Vec<u8>) -> git_object::Data · 25 unmodified lines | ||
| 29 | 32 | ldb().try_find(id, buf).expect("read success").expect("id present") |
| 30 | 33 | } |
| 31 | 34 | |
| 35 | +#[test] | |
| 36 | +#[ignore] | |
| 37 | +fn verify_integrity() { | |
| 38 | + let db = ldb(); | |
| 39 | + let outcome = db.verify_integrity().unwrap(); | |
| 40 | + assert_eq!(outcome.num_objects, 42); | |
| 41 | +} | |
| 42 | + | |
| 32 | 43 | mod write { |
| 33 | 44 | use git_odb::{loose, Write}; |
| 34 | 45 | |
| 35 | − use crate::store::loose::backend::{locate_oid, object_ids}; | |
| 46 | + use crate::store::loose::{locate_oid, object_ids}; | |
| 36 | 47 | |
| 37 | 48 | #[test] |
| 38 | 49 | fn read_and_write() -> Result<(), Box<dyn std::error::Error>> { |
| @@ -66,8 +77,7 @@ mod locate { · 27 unmodified lines | ||
| 66 | 77 | use crate::{ |
| 67 | 78 | hex_to_id, |
| 68 | 79 | store::loose::{ |
| 69 | − backend::{ldb, locate_oid}, | |
| 70 | − signature, | |
| 80 | + signature, {ldb, locate_oid}, | |
| 71 | 81 | }, |
| 72 | 82 | }; |
| 73 | 83 | |
| @@ -210,3 +220,15 @@ cjHJZXWmV4CcRfmLsXzU8s2cR9A0DBvOxhPD1TlKC2JhBFXigjuL9U4Rbq9tdegB · 136 unmodified lines | ||
| 210 | 220 | Ok(()) |
| 211 | 221 | } |
| 212 | 222 | } |
| 223 | + | |
| 224 | +fn signature(time: u32) -> git_actor::SignatureRef<'static> { | |
| 225 | + git_actor::SignatureRef { | |
| 226 | + name: b"Sebastian Thiel".as_bstr(), | |
| 227 | + email: b"byronimo@gmail.com".as_bstr(), | |
| 228 | + time: Time { | |
| 229 | + time, | |
| 230 | + offset: 7200, | |
| 231 | + sign: Sign::Plus, | |
| 232 | + }, | |
| 233 | + } | |
| 234 | +} | |
| @@ -1,16 +0,0 @@ | ||
| 1 | −use git_actor::{Sign, Time}; | |
| 2 | −use git_object::bstr::ByteSlice; | |
| 3 | − | |
| 4 | −pub mod backend; | |
| 5 | − | |
| 6 | −fn signature(time: u32) -> git_actor::SignatureRef<'static> { | |
| 7 | − git_actor::SignatureRef { | |
| 8 | − name: b"Sebastian Thiel".as_bstr(), | |
| 9 | − email: b"byronimo@gmail.com".as_bstr(), | |
| 10 | − time: Time { | |
| 11 | − time, | |
| 12 | − offset: 7200, | |
| 13 | − sign: Sign::Plus, | |
| 14 | − }, | |
| 15 | − } | |
| 16 | −} | |
| @@ -163,7 +163,7 @@ where · 162 unmodified lines | ||
| 163 | 163 | match path.file_name() { |
| 164 | 164 | Some(file_name) if file_name == "multi-pack-index" => { |
| 165 | 165 | let multi_index = git::odb::pack::multi_index::File::at(path)?; |
| 166 | − let res = multi_index.verify_integrity(progress, should_interrupt, git::odb::pack::multi_index::verify::integrity::Options{ | |
| 166 | + let res = multi_index.verify_integrity(progress, should_interrupt, git::odb::pack::index::verify::integrity::Options{ | |
| 167 | 167 | verify_mode: mode, |
| 168 | 168 | traversal: algorithm.into(), |
| 169 | 169 | thread_limit, |