navid/veins / commit
36c23a9f1ae3
Navid <unknown> · 2026-11-30
parents: 0c07122b0d0f
Browse files at this commit · Download source
--- a/veins/src/cli/net_cmd.rs+++ b/veins/src/cli/net_cmd.rs@@ -11,6 +11,7 @@ use crate::object::{TYPE_BLOB, TYPE_COMMIT, TYPE_TREE}; use crate::protocol::client::Client; use crate::protocol::messages::{self, RefInfo, UpdateRef};+use crate::protocol::promisor; use crate::store::Txn; use crate::store::graph; use crate::store::layout;@@ -797,13 +798,11 @@ Ok(walk.output) } -fn missing_objects(client: &mut Client, objects: &[Id]) -> Vec<Id> {+fn missing_objects(client: &mut Client, objects: &[Id]) -> Result<Vec<Id>> { const BATCH: usize = 100_000; let mut missing = Vec::new(); for batch in objects.chunks(BATCH) {- let Ok(bits) = client.have_query(batch) else {- return objects.to_vec();- };+ let bits = client.have_query(batch)?; for (index, id) in batch.iter().enumerate() { if bits.get(index).copied().unwrap_or(0) == 0 { missing.push(*id);@@ -810,7 +809,42 @@ } } }- missing+ Ok(missing)+}++fn fetch_missing_local_chunks(+ root: &Path,+ store: &mut Store,+ commits: &[Id],+ ids: &[Id],+) -> Result<()> {+ let mut absent = Vec::new();+ for id in ids {+ if store.find(*id).is_none() {+ absent.push(*id);+ }+ }+ if absent.is_empty() {+ return Ok(());+ }+ let chunks: HashSet<Id> = chunks_for_commits(store, commits)?.into_iter().collect();+ let fetchable: Vec<Id> = absent+ .iter()+ .copied()+ .filter(|id| chunks.contains(id))+ .collect();+ if !fetchable.is_empty() {+ promisor::fetch_chunks(root, &fetchable)?;+ store.refresh()?;+ store.preload()?;+ }+ if let Some(id) = absent.iter().find(|id| store.find(**id).is_none()) {+ return Err(Error::new(format!(+ "local object is missing: {}",+ id.to_hex()+ )));+ }+ Ok(()) } fn send_chunks(client: &mut Client, root: &Path, chunks: &[Id]) -> Result<()> {@@ -944,8 +978,9 @@ collecting.finish(); } if !objects.is_empty() {- let missing = missing_objects(&mut client, &objects);+ let missing = missing_objects(&mut client, &objects)?; if !missing.is_empty() {+ fetch_missing_local_chunks(&root, &mut store, &commits, &missing)?; let pushing = crate::core::Progress::new("pushing objects", missing.len()); client.push_objects(&root, &missing, Some(&pushing))?; pushing.finish();