cultcache-rs: delete of an unheld key of a homeless type is refused like the put (no-home-delete-unheld-ok)
Some checks failed
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
Some checks failed
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Has been cancelled
delete resolves the type's home store before the held-or-not branch, so is_writable, put and delete agree for a type no store is home to. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
53b13f3974
commit
e6b02d7d65
2 changed files with 17 additions and 1 deletions
|
|
@ -3985,6 +3985,7 @@ impl CultCache {
|
|||
self.require_loaded()?;
|
||||
self.require_entry_type::<T>()?;
|
||||
self.refuse_unread_slots(T::TYPE, key)?;
|
||||
let home = self.home_index(T::TYPE)?;
|
||||
let id = entry_id_parts(T::TYPE, key);
|
||||
let Some(entry) = self.entries.get(&id).cloned() else {
|
||||
if let Some((_, foreign)) = self.foreign.iter().find(|(_, foreign)| foreign.key == key) {
|
||||
|
|
@ -3993,7 +3994,7 @@ impl CultCache {
|
|||
return Ok(false);
|
||||
};
|
||||
let released = self.projected_slots(&entry)?;
|
||||
if let Some(home) = self.home_index(T::TYPE)? {
|
||||
if let Some(home) = home {
|
||||
self.stores[home].store.delete(&entry)?;
|
||||
}
|
||||
self.entries.remove(&id);
|
||||
|
|
|
|||
|
|
@ -477,6 +477,21 @@ fn is_writable_is_false_for_a_type_with_no_home_store() {
|
|||
assert!(cache.is_writable(SlotUnit::TYPE, "k").unwrap());
|
||||
}
|
||||
|
||||
// is_writable and delete agree for a homeless type: removal of an unheld key is refused like the write, not answered false.
|
||||
#[test]
|
||||
fn delete_of_an_unheld_key_of_a_type_with_no_home_store_is_refused_like_the_put() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut cache = registered();
|
||||
cache.add_backing_store(SingleFileMessagePackBackingStore::new(dir.path().join("s.cc")), [SlotUnit::TYPE]).unwrap();
|
||||
cache.pull_all_backing_stores().unwrap();
|
||||
assert!(!cache.is_writable(UnionSurface::TYPE, "k").unwrap());
|
||||
let error = cache.delete::<UnionSurface>("k").unwrap_err();
|
||||
assert!(error.to_string().contains("No backing store is registered"), "{error:#}");
|
||||
// A homed type's unheld delete is still a plain false.
|
||||
assert!(cache.is_writable(SlotUnit::TYPE, "k").unwrap());
|
||||
assert!(!cache.delete::<SlotUnit>("k").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_soa_refuses_a_same_length_replacement_of_a_marked_record() {
|
||||
use cultcache_rs::CultCacheSoaTable;
|
||||
|
|
|
|||
Loading…
Reference in a new issue