This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / knot2 / crates / knot-lfs / src / scan.rs
973 B 32 lines
1use std::collections::BTreeMap; 2 3use knot_git::{Filter, GitError, Haves, PackBudget, Repo, Wants}; 4 5use crate::pointer::{POINTER_MAX_BYTES, parse_pointer}; 6use crate::{ClaimedSize, LfsOid}; 7 8pub fn scan_pointers( 9 repo: &Repo, 10 wants: Wants<'_>, 11 haves: Haves<'_>, 12) -> Result<BTreeMap<LfsOid, ClaimedSize>, GitError> { 13 let selection = repo.select_pack_objects_filtered( 14 wants, 15 haves, 16 Filter::BlobLimit(POINTER_MAX_BYTES + 1), 17 PackBudget::unbounded(), 18 )?; 19 selection 20 .send 21 .iter() 22 .filter_map(|oid| match repo.blob_size(*oid) { 23 Ok(_) => Some(repo.read_blob(*oid)), 24 Err(GitError::ObjectType { .. }) => None, 25 Err(fault) => Some(Err(fault)), 26 }) 27 .filter_map(|blob| match blob { 28 Ok(bytes) => parse_pointer(&bytes).map(|pointer| Ok((pointer.oid, pointer.size))), 29 Err(fault) => Some(Err(fault)), 30 }) 31 .collect() 32}