HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/cache/__pycache__/localfs.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlm
Z
e�e�ZddiZddd�Zdd	�Zd
d�Zdd
�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_�listcCs$|r
d|vr
|dSt�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�
__cachedirsr
cCsdt|�iSr�r
r	rrr�init_kwargs%�rcCsdt|�fS)NZlocalfsrr	rrr�get_storage_id)rrc

Cstjj�|tj�|��}zt�|�Wn"ty5}z|jtj	kr+t
d|�d|����WYd}~nd}~wwtjj�||�d��}tj|d�\}}t�
|�z*tjj�|d��}	tj�||	�Wd�n1siwYtjj�||�WdSty�}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_rrr�store-s2����
����r(c
Csd}tjj�|tj�|�|�d��}tj�|�s(tjj�|tj�|�d�}d}tj�|�s6t�d|�iSz4tjj	�
|d��!}|rRtj�|�|Wd�WStj�|�Wd�WS1scwYWdSt
y�}z
td|�d|����d}~ww)	z(
    Fetch information from a file.
    FrT�Cache file "%s" does not exist�rbNz+There was an error reading the cache file "�": )rrrrrr�isfile�log�debugrrr �loadrr)r"r#rZinkey�key_filer'r&rrr�fetchHs* �
(����r1c
Cs|tjj�|tj�|�|�d��}tj�|�st�d|�dSz	t	tj�
|��WSty=}z
td|�d|����d}~ww)z;
    Return the epoch of the mtime for this cache file
    rr)Nz*There was an error reading the mtime for "r+)
rrrrrrr,r-�warning�int�getmtimerr)r"r#rr0r&rrr�updatedbs ���r5c
Cs�|durt�}zB|dur)tjj�|tj�|��}tj�|�s!WdSt�	|�WdStjj�|tj�|�|�d��}tj�
|�sBWdSt�|�WdSty_}z
t
d|�d|����d}~ww)zF
    Remove the key from the cache bank with all the key content.
    NFrzThere was an error removing "r+T)r
rrrrrr�isdir�shutil�rmtreer,�removerr)r"r#r�targetr&rrr�flushrs$ ����r;c
Cs�tjj�|tj�|��}tj�|�sgSzt�|�}Wnty1}z
t	d|�d|����d}~wwg}|D]}|�
d�rJ|�|�|dd���q6|�|�q6|S)zX
    Return an iterable object containing all entries stored in the specified bank.
    z(There was an error accessing directory "r+Nr���)
rrrrrrr6�listdirrr�endswith�append�rstrip)r"rr%�itemsr&�ret�itemrrrr�s��
cCsX|durtjj�|tj�|��}tj�|�Stjj�|tj�|�|�d��}tj�|�S)zB
    Checks if the specified bank contains the specified key.
    Nr)rrrrrrr6r,)r"r#rr%�keyfilerrr�contains�s
 rE)N)NN)�__doc__r�loggingrZos.pathr7rZsalt.payloadrZsalt.utils.atomicfileZsalt.utils.filesZsalt.utils.pathZsalt.exceptionsr�	getLogger�__name__r-Z__func_alias__r
rrr(r1r5r;rrErrrr�<module>s.