1j_ d Z ddlZddlmZ ddlmZ ddlmZmZmZm Z ddl mZ ddlm Z ddlmZ dd lmZmZ dd lmZ dedefd Zeded fd Z G d de ZdS )zHTTP cache implementation. N)contextmanager)datetime)BinaryIO GeneratorOptionalUnion)SeparateBodyBaseCache)SeparateBodyFileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturnc $ t | dd S )N from_cacheF)getattr)r s m/builddir/build/BUILD/cloudlinux-venv-1.0.11/venv/lib/python3.11/site-packages/pip/_internal/network/cache.py is_from_cacher s 8\5111 )NNNc # 6 K dV dS # t $ r Y dS w xY w)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSError r r suppressed_cache_errorsr s: s c e Zd ZdZdeddf fdZdedefdZdedee fd Z d ededdfdZ dded edeee df ddfdZdeddfdZdedee fdZdededdfdZ xZS ) SafeFileCacheaG A file based cache which is safe to use even when the target directory may not be accessible or writable. There is a race condition when two processes try to write and/or read the same entry at the same time, since each entry consists of two separate files (https://github.com/psf/cachecontrol/issues/324). We therefore have additional logic that makes sure that both files to be present before returning an entry; this fixes the read side of the race condition. For the write side, we assume that the server will only ever return the same data for the same URL, which ought to be the case for files pip is downloading. PyPI does not have a mechanism to swap out a wheel for another wheel, for example. If this assumption is not true, the CacheControl issue will need to be fixed. directoryr Nc n | J d t || _ d S )Nz!Cache directory must not be None.)super__init__r )selfr __class__s r r zSafeFileCache.__init__2 s9 $$&I$$$ "r namec t j | }t |d d |gz }t j j | j g|R S )N )r encodelistospathjoinr )r! r# hashedpartss r _get_cache_pathzSafeFileCache._get_cache_path7 sL '-d33VBQBZ F8+w|DN3U3333r keyc | | }|dz }t j | rt j | sd S t 5 t |d 5 }| cd d d cd d d S # 1 swxY w Y d d d d S # 1 swxY w Y d S N.bodyrb)r- r( r) existsr openread)r! r. metadata_path body_pathfs r getzSafeFileCache.get? sY ,,S11 !G+ }-- "'..2K2K 4 $ & &