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__/mem.cpython-310.pyc
o

;j
�@svdZddlmZddlmZmZddlmZmZddl	m
Z
mZddlm
Z
mZddlmZdZGd	d
�d
ee�ZdS)z*Contains the MemoryDatabase implementation�)�
LooseObjectDB)�	ObjectDBR�	ObjectDBW)�OStream�IStream)�	BadObject�UnsupportedOperation)�ZippedStoreShaWriter�DecompressMemMapReader)�BytesIO)�MemoryDBcs`eZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)ra/A memory database stores everything to memory, providing fast IO and object
    retrieval. It should be used to buffer results and obtain SHAs before writing
    it to the actual physical storage, as it allows to query whether object already
    exists in the target storage before introducing actual IOcs t���td�|_t�|_dS)Nzpath/doesnt/matter)�super�__init__r�_db�dict�_cache��self��	__class__��@/opt/saltstack/salt/lib/python3.10/site-packages/gitdb/db/mem.pyr's

zMemoryDB.__init__cCstd��)Nz$MemoryDB's always stream into memory)r)r�streamrrr�set_ostream.szMemoryDB.set_ostreamcCs`t�}|j�|�|j�|�}|��|�d�t|��dd�}t|j	|j
|j|�|j|j	<|S)NrF)Zclose_on_deletion)
r	rr�store�close�seekr
�getvaluerZbinsha�type�sizer)r�istreamZzstreamZ
decomp_streamrrrr1s
zMemoryDB.storecCs
||jvS�N)r�r�sharrr�
has_object@�
zMemoryDB.has_objectcCs
|�|�Sr!)rr"rrr�infoCs
z
MemoryDB.infoc
Cs@z|j|}|j�d�|WSty}zt|�|�d}~ww)Nr)rrr�KeyErrorr)rr#�ostream�errrrGs

��zMemoryDB.streamcCs
t|j�Sr!)�lenrrrrrrQr%z
MemoryDB.sizecCs
|j��Sr!)r�keysrrrr�sha_iterTr%zMemoryDB.sha_itercCsZd}|D]&}|�|�rq|�|�}t|j���}t|j|j||�}|�|�|d7}q|S)arCopy the streams as identified by sha's yielded by sha_iter into the given odb
        The streams will be copied directly
        **Note:** the object will only be written if it did not exist in the target db

        :return: amount of streams actually copied into odb. If smaller than the amount
            of input shas, one or more objects did already exist in odbr�)r$rr�datarrrr)rr,Zodb�countr#r(�sior rrr�stream_copyXs



zMemoryDB.stream_copy)�__name__�
__module__�__qualname__�__doc__rrrr$r&rrr,r1�
__classcell__rrrrr s
rN)r5Zgitdb.db.looserZ
gitdb.db.baserrZ
gitdb.baserrZ	gitdb.excrrZgitdb.streamr	r
�ior�__all__rrrrr�<module>s