7f_dZddlZddlmZddlmZddlmZmZmZm Z ddl m Z ddl m Z ddlmZdd lmZmZdd lmZd ed efd Zed edfdZGdde ZdS)zHTTP cache implementation. N)contextmanager)datetime)BinaryIO GeneratorOptionalUnion)SeparateBodyBaseCache)SeparateBodyFileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturnc$t|ddS)N from_cacheF)getattr)rs {/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/network/cache.py is_from_cachers 8\5 1 11)NNNc#6K dVdS#t$rYdSwxYw)zvIf we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. N)OSErrorrrsuppressed_cache_errorsrs:         s  c eZdZdZdeddffd ZdedefdZdedeefd Z d ed eddfd Z dded ede e e dfddfdZdeddfdZdedeefdZdededdfdZxZS) 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. directoryrNcn| Jdt||_dS)Nz!Cache directory must not be None.)super__init__r)selfr __class__s rr zSafeFileCache.__init__2s9$$&I$$$ "rnamectj|}t|dd|gz}tjj|jg|RS)N)r encodelistospathjoinr)r!r#hashedpartss r_get_cache_pathzSafeFileCache._get_cache_path7sL'-d33VBQBZ  F8+w|DN3U3333rkeyc||}|dz}tj|rtj|sdSt 5t |d5}|cdddcdddS#1swxYwY ddddS#1swxYwYdSN.bodyrb)r-r(r)existsropenread)r!r. metadata_path body_pathfs rgetzSafeFileCache.get?sY,,S11 !G+ }-- "'..2K2K 4 $ & &  mT** avvxx                                          s6)C:B' C'B+ +C.B+ /CCCr)datacNt5ttj|t |5}||dddn #1swxYwYt|j|ddddS#1swxYwYdSN) rrr(r)dirnamer writer r#)r!r)r:r8s r_writezSafeFileCache._writeIs $ & & " " rwt,, - - -"4(( A                 AFD ! ! !  " " " " " " " " " " " " " " " " " "s5r^sP %%%%%%777777777777@@@@@@AAAAAA000000EEEEEEEE//////2H22222 +;!<    J J J J J )J J J J J r