Phase 6c fix: TagStore delete/contains also see stamped #74
@@ -268,22 +268,39 @@ impl TagStore {
|
||||
/// no such tag existed.
|
||||
pub async fn delete(&self, key: &str) -> Result<bool> {
|
||||
validate_key(key)?;
|
||||
let path = self.tag_path(key);
|
||||
match tokio::fs::remove_file(&path).await {
|
||||
Ok(()) => Ok(true),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(false),
|
||||
Err(e) => Err(anyhow::Error::from(e)),
|
||||
// Phase 6c fix (2026-07-14): try both layers. Modern pins
|
||||
// land in tags-v2/; without unlinking the stamped file too,
|
||||
// `unpin` prints "no such tag" and leaves the tag behind.
|
||||
let mut removed = false;
|
||||
let legacy = self.tag_path(key);
|
||||
match tokio::fs::remove_file(&legacy).await {
|
||||
Ok(()) => removed = true,
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Err(e) => return Err(anyhow::Error::from(e)),
|
||||
}
|
||||
let stamped = self.stamped_tag_path(key);
|
||||
match tokio::fs::remove_file(&stamped).await {
|
||||
Ok(()) => removed = true,
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Err(e) => return Err(anyhow::Error::from(e)),
|
||||
}
|
||||
// Also clear any TTL sidecar.
|
||||
let expiry = self.stamped_expiry_path(key);
|
||||
let _ = tokio::fs::remove_file(&expiry).await;
|
||||
Ok(removed)
|
||||
}
|
||||
|
||||
/// Whether a tag with the given name exists.
|
||||
pub async fn contains(&self, key: &str) -> Result<bool> {
|
||||
validate_key(key)?;
|
||||
match tokio::fs::metadata(self.tag_path(key)).await {
|
||||
Ok(_) => Ok(true),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(false),
|
||||
Err(e) => Err(anyhow::Error::from(e)),
|
||||
// Same fallthrough as get(): visible via either layer counts.
|
||||
if tokio::fs::metadata(self.tag_path(key)).await.is_ok() {
|
||||
return Ok(true);
|
||||
}
|
||||
if tokio::fs::metadata(self.stamped_tag_path(key)).await.is_ok() {
|
||||
return Ok(true);
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
/// List every stored tag. Sorted by key for deterministic output.
|
||||
|
||||
Reference in New Issue
Block a user