File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/__pycache__/localfs.cpython-310.pyc
o
�N�g� � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl Zddl
ZddlZddlm
Z
e�e�ZddiZddd�Zdd � Zd
d� Zdd
� Zdd� Zdd� Zddd�Zdd� Zdd� ZdS )a+
Cache data in filesystem.
.. versionadded:: 2016.11.0
The ``localfs`` Minion cache module is the default cache module and does not
require any configuration.
Expiration values can be set in the relevant config file (``/etc/salt/master`` for
the master, ``/etc/salt/cloud`` for Salt Cloud, etc).
� N)�SaltCacheError�list_�listc C s$ | r
d| v r
| d S t �dtjj�S �N�cachedir)Z__opts__�get�saltZsyspathsZ CACHE_DIR��kwargs� r �F/opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/localfs.py�
__cachedir s r
c C s dt | �iS r �r
r r r r �init_kwargs% � r c C s dt | �fS )NZlocalfsr r r r r �get_storage_id) r r c
C s t jj�|tj�| ��}zt�|� W n" ty5 } z|jtj kr+t
d|� d|� ���W Y d}~nd}~ww t jj�||� d��}tj|d�\}}t�
|� z*t jj�|d��} t j�|| � W d � n1 siw Y t jj�||� W dS ty� } z
t
d|� d|� ���d}~ww ) z&
Store information in a file.
zThe cache directory, z, could not be created: N�.p)�dirzw+bz+There was an error writing the cache file, z: )r �utils�path�join�os�normpath�makedirs�OSError�errnoZEEXISTr �tempfileZmkstemp�close�files�fopen�payload�dumpZ
atomicfileZ
atomic_rename)
�bank�key�datar �base�excZoutfileZtmpfhZtmpfname�fh_r r r �store- s2 ����
����r( c
C s d}t jj�|tj�| �|� d��}tj�|�s(t jj�|tj�| �d �}d}tj�|�s6t�d|� i S z4t jj �
|d��!}|rRt j�|�| W d � W S t j�|�W d � W S 1 scw Y W dS t
y� } z
td|� d|� ���d}~ww ) z(
Fetch information from a file.
Fr T�Cache file "%s" does not exist�rbNz+There was an error reading the cache file "�": )r r r r r r �isfile�log�debugr r r �loadr r )r"