HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/borg/testsuite/__pycache__/cache.cpython-39.opt-1.pyc
a

HZ�h.$�@s�ddlZddlZddlmZddlZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZdd
lmZddlmZmZddlmZdd
lmZGdd�d�ZGdd�d�ZdS)�N�)�packb�)�H)�TestKey)�
Statistics��
AdHocCache)�CompressionSpec)�RepoKey)�
ChunkIndex�CacheSynchronizer)�Manifest)�
Repositoryc@s:eZdZejdd��Zejdd��Zdd�Zdd�Zd	d
�Z	ej
jddd
idfed�ddgfdddddfgd�d�ej
�ddd�dd�dd�f�dd���Z
ej
�d d!ed"�d
d#d$fgid%fd!ed"�d
fgid%fd!d&gid'fd!ded"�d
fgid'fd!ed"�d(d
fgid)ff�d*d+��Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4S)5�TestCacheSynchronizercCst�S�N)r)�self�r�:/usr/lib64/python3.9/site-packages/borg/testsuite/cache.py�indexszTestCacheSynchronizer.indexcCst|�Sr)r
)rrrrr�syncszTestCacheSynchronizer.synccCs"tddddgd��}|�|�dS)N�bar���.�chunks�ZfooZbazr�userr)r�feed�rrr�datarrr�test_no_chunkss�
z$TestCacheSynchronizer.test_no_chunksc	Cs:tddddtd�ddftd�ddfgd��}|�|�dS)	Nrrrrrr�r�rrrrrrr�test_simple's��

z!TestCacheSynchronizer.test_simplec	Cs�tddddtd�ddftd�ddfgd��}|tdd	d
�dgd��7}|tdd	d
�td�ddftd�ddfgdgd
��7}|tdtd�ddfgi�7}|tdtd�ddfgi�7}|dd�}|dd�}|dd�}|�|�|�|�|�|�dS)Nrrrrrrr!rZ123456)zsecurity.foor�rrr!)�xattrs�stuff)r%rr&�F�xr")rrrrZpart1Zpart2Zpart3rrr�
test_multiple7sV��
���
	����

����


z#TestCacheSynchronizer.test_multiplez
elem,errorrrzUnexpected object: map��z$Unexpected bytes in chunks structurezIncorrect key length)r�Unexpected object: integer)��?�Unexpected object: double)TzUnexpected object: true)FzUnexpected object: false)NzUnexpected object: nil)�map�bytes�intZdouble�trueZfalse�none)Zids�	structurecCsd|iS�Nrr��elemrrr�<lambda>z�zTestCacheSynchronizer.<lambda>cCs
d|giSr4rr5rrrr7{r8cCsd|ddfgiS)Nrrrrr5rrrr7|r8cCsbt||��}t�t��}|�|�Wd�n1s60Yt|t�rP|g}dd�|D�}dS)NcSsg|]}d|�qS)zcache_sync_feed failed: r)�.0�errorrrr�
<listcomp>�r8z8TestCacheSynchronizer.test_corrupted.<locals>.<listcomp>)r�pytest�raises�
ValueErrorr�
isinstance�str)rrr3r6r:�packed�excinfoZpossible_errorsrrr�test_corruptedns(
z$TestCacheSynchronizer.test_corruptedz
data,errorr� r!�zInvalid chunk list entry lengthr$r+r,r-cCs@t|�}t�t��}|�|�Wd�n1s20YdSr)rr<r=r>r)rrrrr:rArBrrr�test_corrupted_ancillary�s
(z.TestCacheSynchronizer.test_corrupted_ancillarycCs�t��}|�d�|�d�dd��|�d�dd��|�d�dd��|�d�dd��|�td��|�|�dd��|�d�dd��|�d	�dd��|�d�t�|�}|S)
NsBORG_IDXrrE�littlerD�rrr)�io�BytesIO�write�to_bytesr�seekr�read)rZrefcountZ
index_datarrrr�make_index_with_refcount�s


z.TestCacheSynchronizer.make_index_with_refcountcCsh|�tjd�}t|�}tdtd�ddfgi�}t�t��}|�	|�Wd�n1sZ0YdS�Nrrrr)
rOr�	MAX_VALUEr
rrr<r=r>r)rrrrrBrrr�test_corrupted_refcount�s��(z-TestCacheSynchronizer.test_corrupted_refcountcCs:|�tj�}t|�}tdtd�ddfgi�}|�|�dS)Nrrrr�rOrrQr
rrrrrrr�test_refcount_max_value�s��
z-TestCacheSynchronizer.test_refcount_max_valuecCsH|�tjd�}t|�}tdtd�ddfgi�}|�|�|�|�dSrPrSrrrr�!test_refcount_one_below_max_value�s��

z7TestCacheSynchronizer.test_refcount_one_below_max_valueN)�__name__�
__module__�__qualname__r<�fixturerrr r#r)ZmarkZparametrizer/rCrFrOrRrTrUrrrrrsN

7
��
��	�	
rc@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�TestAdHocCacheccsltj�t|�d�|_t|jddd��4}|�td�d�|�tj	d�|VWd�n1s^0YdS)N�
repositoryT)Z	exclusive�creaters1234�5678)
�os�path�joinr@Zrepository_locationrZputrrZMANIFEST_ID)rZtmpdirr[rrrr[�s
zTestAdHocCache.repositorycCs,|�dd�t�|t���}td�j|_|S)NZBORG_PASSPHRASE�testr2)Zsetenvrr\rZMockArgsr
Z
compressor)rr[Zmonkeypatch�keyrrrrb�szTestAdHocCache.keycCs$t||���tj||tjd�dS)N)rbZ
operationsr)rrK�loadZNO_OPERATION_CHECK)rr[rbrrr�manifest�szTestAdHocCache.manifestcCst|||�Srr)rr[rbrdrrr�cache�szTestAdHocCache.cachecCsdSrr�rrerrr�test_does_not_contain_manifest�sz-TestAdHocCache.test_does_not_contain_manifestcCs|�td�t��dS)Nr)�chunk_decrefrr)rr[rerrr�$test_does_not_delete_existing_chunks�sz3TestAdHocCache.test_does_not_delete_existing_chunkscCsFt�t��(|jtd�dt�dd�Wd�n1s80YdS)Nrr]T)Z	overwrite)r<r=�AssertionError�	add_chunkrrrfrrr�test_does_not_overwrite�sz&TestAdHocCache.test_does_not_overwritecCsdSrrrfrrr�test_seen_chunk_add_chunk_size�sz-TestAdHocCache.test_seen_chunk_add_chunk_sizecCsd|�td�dt��|�td�t��t�tj��|�td��Wd�n1sV0YdS)zE.g. checkpoint archives�s1010N)	rkrrrhr<r=rZObjectNotFound�get)rrer[rrr�#test_deletes_chunks_during_lifetime�sz2TestAdHocCache.test_deletes_chunks_during_lifetimecCsdSrrrfrrr�test_files_cacheszTestAdHocCache.test_files_cachecCs|�td��|��dS)Nrn)Z
seen_chunkrZrollbackrfrrr�test_txnszTestAdHocCache.test_txncCsdSrrrfrrr�test_incref_after_add_chunksz*TestAdHocCache.test_incref_after_add_chunkcCsdS)z9This case occurs with part files, see Archive.chunk_file.Nrrfrrr�$test_existing_incref_after_add_chunksz3TestAdHocCache.test_existing_incref_after_add_chunkN)rVrWrXr<rYr[rbrdrergrirlrmrprqrrrsrtrrrrrZ�s"



		rZ)rIZos.pathr^Zhelpers.msgpackrr<Z	hashindexrrbr�archiverrer	�compressr
Z
crypto.keyrrr
Zhelpersrr[rrrZrrrr�<module>s?