node: do not delete cob in cache after fetch
If a peer deletes a COB, it does not mean that the COB should be deleted. This was incorrectly assumed in the `radicle-node` fetch code. To fix this, when a `RefUpdate::Deleted` is seen after a fetch, the cache is updated with the new state of the COB. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
96c65eb2b3
commit
73c120d8d4
|
|
@ -217,8 +217,9 @@ where
|
||||||
let patches = cob::patch::Patches::open(storage)?;
|
let patches = cob::patch::Patches::open(storage)?;
|
||||||
for update in refs {
|
for update in refs {
|
||||||
match update {
|
match update {
|
||||||
RefUpdate::Updated { name, .. } | RefUpdate::Created { name, .. } => {
|
RefUpdate::Updated { name, .. }
|
||||||
match name.to_namespaced() {
|
| RefUpdate::Created { name, .. }
|
||||||
|
| RefUpdate::Deleted { name, .. } => match name.to_namespaced() {
|
||||||
Some(name) => {
|
Some(name) => {
|
||||||
let Some(identifier) = cob::TypedId::from_namespaced(&name)? else {
|
let Some(identifier) = cob::TypedId::from_namespaced(&name)? else {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -248,36 +249,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => continue,
|
None => continue,
|
||||||
}
|
|
||||||
}
|
|
||||||
RefUpdate::Deleted { name, .. } => match name.to_namespaced() {
|
|
||||||
Some(name) => {
|
|
||||||
let Some(identifier) = cob::TypedId::from_namespaced(&name)? else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
if identifier.is_issue() {
|
|
||||||
cob::cache::Remove::<cob::issue::Issue>::remove(cache, &identifier.id)
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(|e| error::Cache::Remove {
|
|
||||||
id: identifier.id,
|
|
||||||
type_name: identifier.type_name,
|
|
||||||
err: e.into(),
|
|
||||||
})?;
|
|
||||||
} else if identifier.is_patch() {
|
|
||||||
cob::cache::Remove::<cob::patch::Patch>::remove(cache, &identifier.id)
|
|
||||||
.map(|_| ())
|
|
||||||
.map_err(
|
|
||||||
|e: <C as cob::cache::Remove<cob::patch::Patch>>::RemoveError| {
|
|
||||||
error::Cache::Remove {
|
|
||||||
id: identifier.id,
|
|
||||||
type_name: identifier.type_name,
|
|
||||||
err: e.into(),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => continue,
|
|
||||||
},
|
},
|
||||||
RefUpdate::Skipped { .. } => { /* Do nothing */ }
|
RefUpdate::Skipped { .. } => { /* Do nothing */ }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue