Skip to content

Commit f77477c

Browse files
authored
Merge branch 'aboutcode-org:main' into fix-custom-artifactory-metadata
2 parents 2321963 + b9df6f9 commit f77477c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/python_inspector/utils_pypi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import attr
3535
import packageurl
3636
import requests
37+
import zipfile
3738
from bs4 import BeautifulSoup
3839
from commoncode import fileutils
3940
from commoncode.hash import multi_checksums
@@ -1698,6 +1699,21 @@ async def get(
16981699

16991700
cache_valid = os.path.exists(cached) and os.path.getsize(cached) > 0
17001701

1702+
# Validate cached wheel/egg files.
1703+
if cache_valid and not as_text:
1704+
if path_or_url.endswith((".whl", ".egg", ".zip")):
1705+
try:
1706+
cached_resolved = os.path.realpath(cached)
1707+
if not zipfile.is_zipfile(cached_resolved):
1708+
if TRACE_DEEP:
1709+
print(f" FILE CACHE INVALID (corrupted zip): {path_or_url}")
1710+
cache_valid = False
1711+
except (FileNotFoundError, OSError):
1712+
# File was deleted/modified by another task - treat as cache miss
1713+
if TRACE_DEEP:
1714+
print(f" FILE CACHE VANISHED during validation: {path_or_url}")
1715+
cache_valid = False
1716+
17011717
if force or not cache_valid:
17021718
if not cache_valid and os.path.exists(cached):
17031719
if TRACE_DEEP:

0 commit comments

Comments
 (0)