dont propagate removes of triples in AppPatch when SU-Set keeps them (some observed are not removed)

pull/37/head
Niko PLP 4 months ago
parent 9fbeccc3f5
commit b6db6b0d76
  1. 22
      ng-verifier/src/commits/transaction.rs

@ -404,8 +404,11 @@ impl Verifier {
self.update_graph(updates).await self.update_graph(updates).await
} }
async fn update_graph(&mut self, updates: Vec<BranchUpdateInfo>) -> Result<(), VerifierError> { async fn update_graph(
let updates_ref = &updates; &mut self,
mut updates: Vec<BranchUpdateInfo>,
) -> Result<(), VerifierError> {
let updates_ref = &mut updates;
let res = self let res = self
.graph_dataset .graph_dataset
.as_ref() .as_ref()
@ -414,7 +417,7 @@ impl Verifier {
move |mut transaction| -> Result<(), ng_oxigraph::oxigraph::store::StorageError> { move |mut transaction| -> Result<(), ng_oxigraph::oxigraph::store::StorageError> {
let reader = transaction.ng_get_reader(); let reader = transaction.ng_get_reader();
for update in updates_ref { for update in updates_ref.iter_mut() {
let commit_name = let commit_name =
NuriV0::commit_graph_name(&update.commit_id, &update.overlay_id); NuriV0::commit_graph_name(&update.commit_id, &update.overlay_id);
let commit_encoded = numeric_encoder::StrHash::new(&commit_name); let commit_encoded = numeric_encoder::StrHash::new(&commit_name);
@ -505,8 +508,8 @@ impl Verifier {
} else { } else {
REMOVED_IN_OTHER REMOVED_IN_OTHER
}; };
let mut to_remove_from_removes: HashSet<usize> = HashSet::new();
for remove in update.transaction.removes.iter() { for (pos, remove) in update.transaction.removes.iter().enumerate() {
let encoded_subject = remove.subject.as_ref().into(); let encoded_subject = remove.subject.as_ref().into();
let encoded_predicate = remove.predicate.as_ref().into(); let encoded_predicate = remove.predicate.as_ref().into();
let encoded_object = remove.object.as_ref().into(); let encoded_object = remove.object.as_ref().into();
@ -548,12 +551,19 @@ impl Verifier {
let triple_ref: TripleRef = remove.into(); let triple_ref: TripleRef = remove.into();
let quad_ref = triple_ref.in_graph(ov_graphname_ref); let quad_ref = triple_ref.in_graph(ov_graphname_ref);
transaction.remove(quad_ref)?; transaction.remove(quad_ref)?;
} else {
to_remove_from_removes.insert(pos);
} }
} }
} }
let mut idx: usize = 0;
update.transaction.removes.retain(|_| {
let retain = !to_remove_from_removes.remove(&idx);
idx += 1;
retain
});
} }
} }
Ok(()) Ok(())
}, },
) )

Loading…
Cancel
Save