Skip to content

Commit 7e12410

Browse files
committed
mandatory key
1 parent c398b50 commit 7e12410

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cacholote/clean.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838

3939
def _get_files_from_cache_entry(
40-
cache_entry: database.CacheEntry, key: str = "file:size"
40+
cache_entry: database.CacheEntry, key: str | None
4141
) -> dict[str, Any]:
4242
result = cache_entry.result
4343
if not isinstance(result, (list, tuple, set)):
@@ -51,7 +51,10 @@ def _get_files_from_cache_entry(
5151
and obj["callable"] in FILE_RESULT_CALLABLES
5252
):
5353
fs, urlpath = extra_encoders._get_fs_and_urlpath(*obj["args"][:2])
54-
files[fs.unstrip_protocol(urlpath)] = obj["args"][0][key]
54+
value = obj["args"][0]
55+
if key is not None:
56+
value = value[key]
57+
files[fs.unstrip_protocol(urlpath)] = value
5558
return files
5659

5760

@@ -257,7 +260,7 @@ def delete_cache_files(
257260
for cache_entry in session.scalars(
258261
sa.select(database.CacheEntry).filter(*filters).order_by(*sorters)
259262
):
260-
files = _get_files_from_cache_entry(cache_entry)
263+
files = _get_files_from_cache_entry(cache_entry, key="file:size")
261264
if any(file.startswith(self.urldir) for file in files):
262265
entries_to_delete.append(cache_entry)
263266
for file in files:

0 commit comments

Comments
 (0)