mirror of
https://github.com/beshu-tech/deltaglider.git
synced 2026-07-07 13:35:13 +02:00
fix: Add .delta suffix fallback for delete_object()
- delete_object() now tries with .delta suffix if file not found - Matches the same fallback logic as download/get_object - Fixes deletion of files uploaded as .delta when user provides original name - Add test for delta suffix fallback in deletion This fixes the critical bug where delete_object(Key='file.zip') would fail with NotFoundError when the actual file was stored as 'file.zip.delta'. Now delete_object() works consistently with get_object(): - Try with key as provided - If NotFoundError and no .delta suffix, try with .delta appended - Raises NotFoundError only if both attempts fail 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ from typing import Any
|
||||
|
||||
from .adapters.storage_s3 import S3StorageAdapter
|
||||
from .core import DeltaService, DeltaSpace, ObjectKey
|
||||
from .core.errors import NotFoundError
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -427,15 +428,23 @@ class DeltaGliderClient:
|
||||
|
||||
Args:
|
||||
Bucket: S3 bucket name
|
||||
Key: Object key
|
||||
Key: Object key (can be with or without .delta suffix)
|
||||
**kwargs: Additional parameters
|
||||
|
||||
Returns:
|
||||
Response dict with deletion details
|
||||
"""
|
||||
# Use core service's delta-aware delete
|
||||
# Try to delete with the key as provided
|
||||
object_key = ObjectKey(bucket=Bucket, key=Key)
|
||||
delete_result = self.service.delete(object_key)
|
||||
try:
|
||||
delete_result = self.service.delete(object_key)
|
||||
except NotFoundError:
|
||||
# Try with .delta suffix if not already present
|
||||
if not Key.endswith(".delta"):
|
||||
object_key = ObjectKey(bucket=Bucket, key=Key + ".delta")
|
||||
delete_result = self.service.delete(object_key)
|
||||
else:
|
||||
raise
|
||||
|
||||
response = {
|
||||
"DeleteMarker": False,
|
||||
|
||||
Reference in New Issue
Block a user