File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 3434import attr
3535import packageurl
3636import requests
37+ import zipfile
3738from bs4 import BeautifulSoup
3839from commoncode import fileutils
3940from 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 :
You can’t perform that action at this time.
0 commit comments