Add local CAS pin metadata

This commit is contained in:
Eric Wendland 2026-05-16 16:36:35 +02:00
commit 00471bcec0
9 changed files with 169 additions and 16 deletions

View file

@ -225,18 +225,38 @@ pub fn handle_request(
let present = cas.has(&hash)?;
Ok(ControlResponse::CasHas { hash, present })
}
ControlRequest::CasPin { hash } => {
let cas = LocalCas::new(node.paths.cas_dir());
if !cas.has(&hash)? {
return Err(NodeError::Cas(geth_cas::CasError::NotFound(
hash.to_string(),
)));
}
store.pin_cas_object(hash.as_str())?;
Ok(ControlResponse::CasPinned { hash, pinned: true })
}
ControlRequest::CasUnpin { hash } => {
geth_cas::validate_hash(&hash)?;
store.unpin_cas_object(hash.as_str())?;
Ok(ControlResponse::CasPinned {
hash,
pinned: false,
})
}
ControlRequest::CasList => {
let cas = LocalCas::new(node.paths.cas_dir());
Ok(ControlResponse::CasList {
blobs: cas
.list()?
.into_iter()
.map(|blob| CasBlob {
let blobs = cas
.list()?
.into_iter()
.map(|blob| {
Ok(CasBlob {
pinned: store.is_cas_object_pinned(blob.hash.as_str())?,
hash: blob.hash,
size_bytes: blob.size_bytes,
})
.collect(),
})
})
.collect::<Result<Vec<_>, NodeError>>()?;
Ok(ControlResponse::CasList { blobs })
}
ControlRequest::KeychainInit { admin_key_path } => {
let mut ops = Vec::new();