Skip to content

Commit da03d56

Browse files
committed
fix(file_storage): log orphaned thumbnail variant deletes (review round 1, pass 3)
Claude-Session: https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4
1 parent fd5f78d commit da03d56

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎modules/file_storage/file_storage/thumbnails.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import asyncio
1919
import io
20+
import logging
2021
import struct
2122
import weakref
2223
from typing import TYPE_CHECKING
@@ -29,6 +30,8 @@
2930
if TYPE_CHECKING:
3031
from file_storage.contracts.service import StorageBackend
3132

33+
_logger = logging.getLogger(__name__)
34+
3235

3336
class NotAnImageError(Exception):
3437
"""The file's type has no thumbnail (not a raster image, or SVG)."""
@@ -206,7 +209,12 @@ async def _once():
206209

207210
async def delete_variants(backend: StorageBackend, key: str) -> None:
208211
"""Drop every cached variant of ``key``; absent ones are fine."""
209-
await asyncio.gather(
212+
results = await asyncio.gather(
210213
*(backend.delete(variant_key(key, width)) for width in constants.THUMBNAIL_WIDTHS),
211214
return_exceptions=True,
212215
)
216+
for result in results:
217+
# An absent variant is the common case; anything else is an orphan
218+
# nobody would otherwise learn about.
219+
if isinstance(result, Exception) and not isinstance(result, StorageNotFoundError):
220+
_logger.warning("file_storage.variant_delete_failed key=%s error=%r", key, result)

0 commit comments

Comments
 (0)