HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/gitdb/db/__pycache__/loose.cpython-310.pyc
o

;j"�@s�ddlmZddlmZmZmZddlmZmZddl	m
Z
mZmZm
Z
ddlmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZddlmZm Z m!Z!m"Z"ddl#m$Z$dd	l%Z%dd	l&Z&dd	l'Z'dd	l(Z(d
Z)Gdd�deee�Z*d	S)
�)�suppress)�
FileDBBase�	ObjectDBR�	ObjectDBW)�	BadObject�AmbiguousObjectName)�DecompressMemMapReader�FDCompressedSha1Writer�FDStream�
Sha1Writer)�OStream�OInfo)�file_contents_ro_filepath�ENOENT�
hex_to_bin�
bin_to_hex�exists�chmod�isfile�remove�rename�dirname�basename�join)�
chunk_size�loose_object_header_info�write_object�stream_copy)�force_bytesN)�
LooseObjectDBcs�eZdZdZeZedd�Zej	dkredd�Z�fdd�Z
dd	�Zd
d�Zdd
�Z
dd�Z�fdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�ZS)rz/A database which operates on loose object filesZ444��ntZ644cs&t��|�t�|_ttdd�|_dS)N�	O_NOATIMEr)�super�__init__�dict�_hexsha_to_file�getattr�os�_fd_open_flags)�self�	root_path��	__class__��B/opt/saltstack/salt/lib/python3.10/site-packages/gitdb/db/loose.pyr$MszLooseObjectDB.__init__cCst|dd�|dd��S)z{
        :return: path at which the object with the given hexsha would be stored,
            relative to the database rootN�)r)r*�hexshar.r.r/�object_pathVszLooseObjectDB.object_pathcCs`tt��
|j|Wd�S1swY|�|�|��}t|�r,||j|<|St|��)z�
        :return: readable object path to the object identified by hexsha
        :raise BadObject: If the object file does not existN)r�KeyErrorr&�db_pathr2rr)r*r1�pathr.r.r/�readable_db_object_path\s
 �
z%LooseObjectDB.readable_db_object_pathcCsLd}|��D]}t|��t|��r|durt|��|}q|dur$t|��|S)z�:return: 20 byte binary sha1 string which matches the given name uniquely
        :param name: hexadecimal partial name (bytes or ascii string)
        :raise AmbiguousObjectName:
        :raise BadObject: N)�sha_iterr�
startswithrrr)r*Zpartial_hexsha�	candidate�binshar.r.r/�partial_to_complete_sha_hexls�z)LooseObjectDB.partial_to_complete_sha_hexc
Cs�|�|�t|���}zt||jd�WStyE}z'|jtkr<zt|�WWYd}~Sty;}zt|�|�d}~wwt|�|�d}~ww)z~
        :return: memory map of that file to allow random read access
        :raise BadObject: if object could not be located)�flagsN)	r4r2rrr)�OSError�errnorr)r*�shar4�eZnew_er.r.r/�_map_loose_objects

��
��zLooseObjectDB._map_loose_objectcs,|durt|t�stdtj��t��|�S)zI:raise TypeError: if the stream does not support the Sha1Writer interfaceNz,Output stream musst support the %s interface)�
isinstancer�	TypeError�__name__r#�set_ostream)r*�streamr,r.r/rE�szLooseObjectDB.set_ostreamc	CsP|�|�}zt|�\}}t|||�Wt|d�r|��SSt|d�r'|��ww)N�close)rArr
�hasattrrG)r*r?�m�typ�sizer.r.r/�info�s


�
�zLooseObjectDB.infocCs,|�|�}tj|dd�\}}}t||||�S)NT)Zclose_on_deletion)rAr�newr)r*r?rI�typerKrFr.r.r/rF�s
zLooseObjectDB.streamcCs*z
|�t|��WdStyYdSw)NTF)r6rr)r*r?r.r.r/�
has_object�s�zLooseObjectDB.has_objectc		Cs�d}|��}|dur"tjd|jd�\}}|jdurt|�}nt|�}z2z'|jdur5t|j|j	t
j|j�nt
|j|j|j|j	|jd�W|rJ|��n|rR|��wwWn
|r^t|��d}|jrh|j}n|jdd�}|r�|�|�|��}t|�}tj|dd�t|�r�t|�nt||�dD]%}tt��t||j�	Wd�n1s�wYt� |d	�q�td
�!|���t"|�|_|S)z.note: The sha we produce will be hex by natureN�obj)�prefix�dir)rT)Zas_hex)�exist_ok)���	���$�1�@�Q�d�y���g@�@z&Impossible to apply `chmod` to file {})#Zostream�tempfileZmkstempZ
_root_pathr:r	r
r�read�write�sys�maxsize�stream_chunk_sizerrNrKrGrr1r?r4r2rr(�makedirsrrr�PermissionErrorr�new_objects_mode�time�sleep�formatr)	r*ZistreamZtmp_path�writer�fdr1Zobj_pathZobj_dirZexp_backoff_msr.r.r/�store�s`


����
��


 ��
zLooseObjectDB.storeccs\�t�|���D]#\}}}t|�}t|�dkrq|D]}t|�dkr#qt||�VqqdS)Nr0�&)r(�walkr+r�lenr)r*�root�dirs�filesZ	root_base�fr.r.r/r7�s���zLooseObjectDB.sha_itercCstt|����S)N)rs�tupler7)r*r.r.r/rKszLooseObjectDB.size)rD�
__module__�__qualname__�__doc__rrg�intrjr(�namer$r2r6r;rArErLrFrOrpr7rK�
__classcell__r.r.r,r/r?s$


	
Lr)+�
contextlibrZ
gitdb.db.baserrrZ	gitdb.excrrZgitdb.streamrr	r
rZ
gitdb.baserr
Z
gitdb.utilrrrrrrrrrrrrZ	gitdb.funrrrrZgitdb.utils.encodingrrbr(rerk�__all__rr.r.r.r/�<module>s8