Sindbad~EG File Manager
�
4Μg_ � �� � 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 �F/usr/local/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'