\h_dZddlZddlmZddlmZddlmZmZmZm Z ddl m Z ddl m Z ddlmZdd lmZmZdd lmZd ed efd Zed edfdZGdde Zy)zHTTP cache implementation. N)contextmanager)datetime)BinaryIO GeneratorOptionalUnion)SeparateBodyBaseCache)SeparateBodyFileCache)Response)adjacent_tmp_filereplace) ensure_dirresponsereturnct|ddS)N from_cacheF)getattr)rs ^/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pip/_internal/network/cache.py is_from_cachers 8\5 11)NNNc#4K dy#t$rYywxYww)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. directoryrNcB|Jdt|||_y)Nz!Cache directory must not be None.)super__init__r)selfr __class__s rr zSafeFileCache.__init__2s'$I&II$ "rnamectj|}t|dd|gz}tjj |j g|S)N)r encodelistospathjoinr)r!r#hashedpartss r_get_cache_pathzSafeFileCache._get_cache_path7sG'--d3VBQZ F8+ww||DNN3U33rkeycd|j|}|dz}tjj|rtjj|syt 5t |d5}|j cdddcdddS#1swYnxYw dddy#1swYyxYwN.bodyrb)r-r(r)existsropenread)r!r. metadata_path body_pathfs rgetzSafeFileCache.get?s,,S1 !G+ }-"''..2K $ & mT* avvx          s$ B&-B= B&B B&&B/r)datac t5ttjj |t |5}|j |dddtj|dddy#1swY(xYw#1swYyxYwN) rrr(r)dirnamer writer r#)r!r)r:r8s r_writezSafeFileCache._writeIsq $ & " rwwt, -"4( A   AFFD !  " "   " "s"4BA8B8B =BB valueexpirescJ|j|}|j||yr<r-r?)r!r.r@rAr)s rsetzSafeFileCache.setRs"##C( D% rc|j|}t5tj|dddt5tj|dzdddy#1swY5xYw#1swYyxYwNr1)r-rr(remove)r!r.r)s rdeletezSafeFileCache.deleteXsh##C( $ &  IIdO  $ & & IIdWn % & &   & &sA&A2&A/2A;c|j|}|dz}tjj|rtjj|syt 5t |dcdddS#1swYyxYwr0)r-r(r)r3rr4)r!r.r6r7s rget_bodyzSafeFileCache.get_body_sc,,S1 !G+ }-"''..2K $ & ) 4( ) ) )s A66A?bodycP|j|dz}|j||yrFrC)r!r.rKr)s rset_bodyzSafeFileCache.set_bodyhs%##C(72 D$rr<)__name__ __module__ __qualname____doc__strr r-rbytesr9r?rintrrDrHrrJrM __classcell__)r"s@rrr s"###$# 4C4C4 s x "3"e""MQ!!$!/4S(D5H/I! ! &#&$&)C)HX$6) C u  rr)rQr( contextlibrrtypingrrrrpip._vendor.cachecontrol.cacher pip._vendor.cachecontrol.cachesr pip._vendor.requests.modelsr pip._internal.utils.filesystemr r pip._internal.utils.miscrboolrrrrrrr^sm %77@A0E/2H22 +;!<  J )J r