관리-도구
편집 파일: cache.cpython-312.pyc
� G��e_ � �� � d Z ddlZddlmZ ddlmZ ddlmZmZmZm Z ddl mZ ddlm Z ddlmZ dd lmZmZ dd lmZ dedefd �Zeded fd�� Z G d� de� Zy)zHTTP cache implementation. � N)�contextmanager)�datetime)�BinaryIO� Generator�Optional�Union)�SeparateBodyBaseCache)�SeparateBodyFileCache)�Response)�adjacent_tmp_file�replace)� ensure_dir�response�returnc � � t | dd� S )N� from_cacheF)�getattr)r s ��/builddir/build/BUILDROOT/alt-python312-pip-23.3.1-1.el8.x86_64/opt/alt/python312/lib/python3.12/site-packages/pip/_internal/network/cache.py� is_from_cacher s � ��8�\�5�1�1� )NNNc # �4 K � d�� y# t $ r Y yw xY w�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� fd�Zdedefd�Zdedee fd �Z d ededdfd�Z dded edeee df ddfd�Zdeddfd�Zdedee fd�Zdededdfd�Z� 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 �B �� |�J d� �t �| � � || _ y )Nz!Cache directory must not be None.)�super�__init__r )�selfr � __class__s �r r zSafeFileCache.__init__2 s$ �� ��$�I�&I�I� ����"��r �namec � � t j |� }t |d d � |gz }t j j | j g|��� S )N� )r �encode�list�os�path�joinr )r! r# �hashed�partss r �_get_cache_pathzSafeFileCache._get_cache_path7 sG � � '�-�-�d�3���V�B�Q�Z� �F�8�+���w�w�|�|�D�N�N�3�U�3�3r �keyc �d � | j |� }|dz }t j j |� rt j j |� sy t � 5 t |d� 5 }|j � cd d d � cd d d � S # 1 sw Y nxY w d d d � y # 1 sw Y y xY w�N�.body�rb)r- r( r) �existsr �open�read)r! r. � metadata_path� body_path�fs r �getzSafeFileCache.get? s� � ��,�,�S�1� �!�G�+� ������}�-�"�'�'�.�.��2K�� $� &� ��m�T�*� �a��v�v�x� � � � � � �� � � � �s$ � B&�-B�= B&�B �B&�&B/r) �datac � � t � 5 t t j j |� � t |� 5 }|j |� d d d � t j |� d d d � y # 1 sw Y �(xY w# 1 sw Y y xY w�N) r r r( r) �dirnamer �writer r# )r! r) r: r8 s r �_writezSafeFileCache._writeI sq � � $� &� "��r�w�w���t�,�-�"�4�(� �A����� � � �A�F�F�D�!� "� "� � �� "� "�s"