refactor: Rename Leaf to DeltaSpace for semantic clarity

- Renamed Leaf class to DeltaSpace throughout the codebase
- Updated all imports, method signatures, and variable names
- Updated documentation and comments to reflect the new naming
- DeltaSpace better represents a container for delta-compressed files

The term "DeltaSpace" is more semantically accurate than "Leaf" as it
represents a space/container for managing related files with delta
compression, not a terminal node in a tree structure.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Simone Scarduzio
2025-09-23 08:05:20 +02:00
parent 0613de9a5e
commit fb3ad0e076
14 changed files with 112 additions and 102 deletions
+8 -8
View File
@@ -15,30 +15,30 @@ class FsCacheAdapter(CachePort):
self.base_dir = base_dir
self.hasher = hasher
def ref_path(self, bucket: str, leaf: str) -> Path:
def ref_path(self, bucket: str, prefix: str) -> Path:
"""Get path where reference should be cached."""
cache_dir = self.base_dir / bucket / leaf
cache_dir = self.base_dir / bucket / prefix
return cache_dir / "reference.bin"
def has_ref(self, bucket: str, leaf: str, sha: str) -> bool:
def has_ref(self, bucket: str, prefix: str, sha: str) -> bool:
"""Check if reference exists and matches SHA."""
path = self.ref_path(bucket, leaf)
path = self.ref_path(bucket, prefix)
if not path.exists():
return False
actual_sha = self.hasher.sha256(path)
return actual_sha == sha
def write_ref(self, bucket: str, leaf: str, src: Path) -> Path:
def write_ref(self, bucket: str, prefix: str, src: Path) -> Path:
"""Cache reference file."""
path = self.ref_path(bucket, leaf)
path = self.ref_path(bucket, prefix)
path.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(src, path)
return path
def evict(self, bucket: str, leaf: str) -> None:
def evict(self, bucket: str, prefix: str) -> None:
"""Remove cached reference."""
path = self.ref_path(bucket, leaf)
path = self.ref_path(bucket, prefix)
if path.exists():
path.unlink()
# Clean up empty directories