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/__pycache__/remote.cpython-39.opt-1.pyc
a

HZ�h���@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZmZddlmZddlmZddlTddlmZmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlm Z ddlm!Z!m"Z"ddl#m$Z$m%Z%ddlm&Z&ddl'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/e$e0�Z#dZ1e*e�Z2d\Z3Z4Z5Z6dZ7dZ8dd�Z9Gdd�de�Z:Gdd�de:�Z;Gd d!�d!e�Z<Gd"d#�d#e�Z=Gd$d%�d%e�Z>Gd&d'�d'e�Z?d(d)d*d*d*d+d,d-d-d.d*d*d/d0d*d1d2�Z@d3d4�ZAGd5d6�d6�ZBGd7d8�d8�ZCd9d:�ZDGd;d<�d<�ZEd=d>�ZFGd?d@�d@�ZGGdAdB�dBeG�ZHdCddddCdD�dEdF�ZIdS)G�N)�Popen�PIPE�)�__version__)�
Compressor)�*)�Error�IntegrityError)�
bin_to_hex)�get_base_dir)�get_limited_unpacker)�replace_placeholders)�sysinfo)�format_file_size)�safe_unlink)�prepare_subprocess_env�
ignore_sigint)�
create_logger�
setup_logging)�msgpack)�
Repository)�
parse_version�format_version)�xxh64)�EfficientCollectionQueue�)�i�m�a�r�d皙�����?cCsJt|�}}|rFt�||�}||8}|s*qF||d�}t�|d�q|S)z;os.write wrapper so we do not lose data for partial writes.Ng��&�.>)�len�os�write�time�sleep)�fd�data�amountZ	remaining�count�r+�1/usr/lib64/python3.9/site-packages/borg/remote.py�os_write0sr-c@seZdZdZdS)�ConnectionClosedz Connection closed by remote hostN��__name__�
__module__�__qualname__�__doc__r+r+r+r,r.Csr.c@seZdZdZdS)�ConnectionClosedWithHintz$Connection closed by remote host. {}Nr/r+r+r+r,r4Gsr4c@seZdZdZdS)�PathNotAllowedzRepository path not allowed: {}Nr/r+r+r+r,r5Ksr5c@seZdZdZdS)�InvalidRPCMethodzRPC method {} is not validNr/r+r+r+r,r6Osr6c@seZdZdZdS)�!UnexpectedRPCDataFormatFromClientz4Borg {}: Got unexpected RPC data format from client.Nr/r+r+r+r,r7Ssr7cs eZdZdZ�fdd�Z�ZS)�!UnexpectedRPCDataFormatFromServerz.Got unexpected RPC data format from server:
{}csdz|��dd�}Wn>tyR|dd�}dd�|D�}t�d�|�d�}Yn0t��|�dS)N�cSsg|]}d|�qS)z%02Xr+)�.0Zbyter+r+r,�
<listcomp>_�z>UnexpectedRPCDataFormatFromServer.__init__.<locals>.<listcomp>� �0)�decode�UnicodeDecodeError�textwrap�fill�join�super�__init__)�selfr(��	__class__r+r,rEZsz*UnexpectedRPCDataFormatFromServer.__init__)r0r1r2r3rE�
__classcell__r+r+rGr,r8Wsr8)�repair�
save_space)rKr+)�limit�marker)�idr(�rN)�keydata)�client_data)�path�create�	lock_wait�lock�	exclusive�append_only)�next_unreserved�start_nonce)�check�commit�rollback�destroy�__len__�list�put�get�delete�save_key�load_key�
break_lock�	negotiate�open�get_free_nonce�commit_nonce_reservationcs�fdd��D�S)Ncsi|]}|���|�qSr+)r?)r:�k��dr+r,�
<dictcomp>�r<zdecode_keys.<locals>.<dictcomp>r+rkr+rkr,�decode_keys�srnc@sReZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dd�ZdS)�RepositoryServer)r^rZr[rbr]rar_�scanrfrgr`r\rcrdrerhri�inject_exceptioncCs,d|_||_||_||_||_td�|_dS)N�1.0.8)�
repository�restrict_to_paths�restrict_to_repositoriesrW�
storage_quotar�client_version)rFrtrurWrvr+r+r,rE�szRepositoryServer.__init__csrz�fdd�tt|�D�WStyl|dkrPt��dkrPt|dd�}n��fdd�t|�D�YS0dS)z5Translate from positional protocol to named protocol.csi|]\}}|�|�qSr+r+�r:�pos�name��argvr+r,rm�r<z8RepositoryServer.positional_to_named.<locals>.<dictcomp>rg�Ncsi|]\}}|�|�qSr+r+rxr{r+r,rm�r<)�	enumerate�	compatMap�
IndexErrorr")rF�methodr|�mappingr+r{r,�positional_to_named�sz$RepositoryServer.positional_to_namedcs$tt�|�j����fdd��D�S)zWRemove unknown named parameters from call, because client did (implicitly) say it's ok.csi|]}|�vr|�|�qSr+r+�r:rz�Zknown�kwargsr+r,rm�r<z0RepositoryServer.filter_args.<locals>.<dictcomp>)�set�inspect�	signature�
parameters)rF�fr�r+r�r,�filter_args�szRepositoryServer.filter_argscCs�tj��}tj��}tj��}t�|d�t�|d�t�|d�td�}t�|gggd�\}}}|�r�t�|t	�}|s�|j
dur�|j
��nt|d�
t����dS|�|�|D�]�}	t|	t�r�d}
|	t}|	t��}t|	t�}
n^t|	t��r*t|	�dk�r*d}
|	\}}}}
|��}|�||
�}
n|j
du�r@|j
��tt��zd||jv�r^t|��zt||�}Wn t�y�t|j
|�}Yn0|� ||
�}
|fi|
��}W�n�t!�yh}�z�|
�r�t"�#|j$|�}t"j%t�&��}d}t|t'��r|�(�g}|j"}t|t)j*t)j+t,f��rnt-�.d�/|��z2t0�1t|d|j$j2d	|j3d
|d|d|d
t4�i�}WnLt5�y�t0�1t|d|j$j2d	dd�|j3D�d
|d|d|d
t4�i�}Yn0t||�n�t|t)j*t)j+t,f��r�nft|t'��r�|j"�r�t-j6nt-j7}|�(�}nt-j6}d|j$j2}t"�8��dt4���}t-�9|�t-�:||�d}t|t0�1d||j$j2|f��WYd}~q�d}~00|
�r�t|t0�1t|t;|i��q�t|t0�1d|d|f��q�|rJ|j
��dSqJdS)NFTZserver�
z<Borg {}: Got connection close before repository was opened.
r}�
�exception_class�exception_args�exception_full�exception_short�exception_trace�sysinfocSs$g|]}t|tttf�r|nd�qS�N)�
isinstance�str�bytes�int)r:�xr+r+r,r;s�z*RepositoryServer.serve.<locals>.<listcomp>z%s Exception in RPC callz3Remote Exception (see remote log for the traceback)r)<�sys�stdin�fileno�stdoutr#�set_blockingr�select�read�BUFSIZErs�closer-�formatr�encode�feedr��dict�MSGID�MSGr?rn�ARGS�tupler"r�r7�rpc_methodsr6�getattr�AttributeErrorr��
BaseException�	traceback�format_exception_onlyrH�format_exception�exc_infor�get_messager�DoesNotExist�
AlreadyExistsr5�logging�debugrCr�packbr0�argsr�	TypeError�ERROR�DEBUG�
format_exc�error�log�RESULT)rF�stdin_fd�	stdout_fd�	stderr_fd�unpacker�r�w�esr(�unpacked�
dictFormat�msgidr�r��_r��res�eZex_shortZex_fullZex_trace�msgZtb_log_level�tb�excr+r+r,�serve�s�



�





�
��	

2
zRepositoryServer.servecCsZ|tkrtSt|t�rL|d|_t�t�d�j�}tdd|d�t	�
d�nt|_dtiS)N�client_version�T)Zis_serve�json�levelz2Initialized logging system for JSON-based protocol�server_version)�RPC_PROTOCOL_VERSIONr�r�rwr�ZgetLevelName�	getLoggerr�r�loggerr��BORG_VERSION)rFrQr�r+r+r,rf/s

zRepositoryServer.negotiatecCs�t|t�rt�|�}|�d�r8tj�t�|dd��}nr|�d�r\tj�t�|dd��}nN|�d�r|tj�|dd��}n.|�d�r�tj�|�}n|�d�r�|dd�}tj�	|�S)	Nz/~/�z~/rz/~r�~z/./)
r�r�r#�fsdecode�
startswithrRrCr�
expanduser�realpath)rFrRr+r+r,�
_resolve_path@s






zRepositoryServer._resolve_pathFNTc

Cs�t�d|�|�|�}t�d|�tj�|d�}|jrn|jD](}	tj�tj�|	�d�}
|�|
�r<qnq<t	|��|j
r�|j
D]&}tj�tj�|�d�}||krzq�qzt	|��|r�|jp�|}t||||||j
||d�|_|j��|jjS)NzResolving repository path %rzResolved repository path to %rr�)rTrUrWrvrV�make_parent_dirs)r�r�r�r#rRrCrtr�r�r5rurWrrvrs�	__enter__rN)
rFrRrSrTrUrVrWr�Z
path_with_sepZrestrict_to_pathZrestrict_to_path_with_sepZrestrict_to_repositoryZrestrict_to_repository_with_sepr+r+r,rgPs2




�
zRepositoryServer.opencCs�|��}d}d}|dkr$t�|��n�|dkr8t�|��np|dkrLt�|��n\|dkr^t|��nJ|dkrptd��n8|d	kr�t�||��n"|d
kr�t|��n|dkr�dddS)
Nztest stringztest string2r�r��CheckNeededr	r5Zfoo�ObjectNotFoundr6Zdivider)	r?rr�r�r�r	r5r�r6)rF�kind�s1�s2r+r+r,rqss&


z!RepositoryServer.inject_exception)FNTNFF)r0r1r2r�rEr�r�r�rfr�rgrqr+r+r+r,ro�sk�
#roc@seZdZdd�Zdd�ZdS)�SleepingBandwidthLimitercCs0|r&t|t�|_t��|_|j|_nd|_dSr�)r��RATELIMIT_PERIOD�	ratelimitr%�	monotonic�ratelimit_last�ratelimit_quota)rFrLr+r+r,rE�s


z!SleepingBandwidthLimiter.__init__cCs�|jr�t��}|jt|krN|j|j7_|jd|jkrHd|j|_||_|jdkr�|jt|}t�|�|j|j7_t��|_t|�|jkr�|d|j�}t�	||�}|jr�|j|8_|S)Nrr)
r�r%r�r�r�r�r&r"r#r$)rFr'�to_sendZnowZtosleep�writtenr+r+r,r$�s$


zSleepingBandwidthLimiter.writeN)r0r1r2rEr$r+r+r+r,r��sr�cs��fdd�}|S)aSCheck version requirements and use self.call to do the remote method call.

    <since> specifies the version in which borg introduced this method.
    Calling this method when connected to an older version will fail without transmitting anything to the server.

    Further kwargs can be used to encode version specific restrictions:

    <previously> is the value resulting in the behaviour before introducing the new parameter.
    If a previous hardcoded behaviour is parameterized in a version, this allows calls that use the previously
    hardcoded behaviour to pass through and generates an error if another behaviour is requested by the client.
    E.g. when 'append_only' was introduced in 1.0.7 the previous behaviour was what now is append_only=False.
    Thus @api(..., append_only={'since': parse_version('1.0.7'), 'previously': False}) allows calls
    with append_only=False for all version but rejects calls using append_only=True on versions older than 1.0.7.

    <dontcare> is a flag to set the behaviour if an old version is called the new way.
    If set to True, the method is called without the (not yet supported) parameter (this should be done if that is the
    more desirable behaviour). If False, an exception is generated.
    E.g. before 'threshold' was introduced in 1.2.0a8, a hardcoded threshold of 0.1 was used in commit().
    cst������fdd��}|S)Nc
	s6t���}|j|g|�Ri|��}i}i}|j��D]Z\}}|dkrFq4||jvrx|dkrh|j|||<q�|j|||<q4|j|jur4|j||<q4|j�kr�|�	�j
t�������D]j\}}	|	d|jkr�q�d|	vr�|||	dkr�q�|	�dd�r�q�|�	�j
�d|�d||��t|	d���q�|j
�j
|fi|��S)	NrF�wait�since�
previously�dontcareFr=�=)r�r�Zbindr��itemsZ	arguments�default�emptyr��RPCServerOutdatedr0rra�call)
rFr�r�ZsigZ
bound_argsZnamedZextrarzZparamZrestriction)r��kwargs_decoratorr�r+r,�do_rpc�s4



�z&api.<locals>.decorator.<locals>.do_rpc)�	functools�wraps)r�r��r�r�)r�r,�	decorator�s zapi.<locals>.decoratorr+)r�r�rr+rr,�api�s#rc@sfeZdZgZGdd�de�ZGdd�de�ZdZdUdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
edd��Zdd�Zdd�Zdd�Zdd�ZdVdd�Zeed�ed�dd �ed!�dd �d"�dWd#d$��Zeed�ed%�d&d �d'�dXd(d)��Zeed�ed*�ddd+�ed,�d-dd+�ed*�ddd+�d.�dYd/d0��Zeed�d1�d2d3��Zeed�d1�d4d5��Zeed�d1�d6d7��Zeed�d1�dZd8d9��Zeed:�d1�d[d;d<��Zd=d>�Zd\d?d@�Z eed�d1�d]dAdB��Z!eed�d1�d^dCdD��Z"eed�d1�dEdF��Z#eed�d1�dGdH��Z$eed�d1�dIdJ��Z%eed�d1�dKdL��Z&eed�d1�dMdN��Z'dOdP�Z(d_dQdR�Z)dSdT�Z*dS)`�RemoteRepositoryc@sLeZdZdd�Zdd�Zedd��Zedd��Zed	d
��Zedd��Z	d
S)zRemoteRepository.RPCErrorcCs
||_dSr�)r�)rFr�r+r+r,rE�sz"RemoteRepository.RPCError.__init__cCs(d|jvrd�|jd���S|jSdS)Nr��
)r�rCr?�exception_class�rFr+r+r,r��s
z%RemoteRepository.RPCError.get_messagecCs|j�dd�S)Nr�T)r�rarr+r+r,r��sz#RemoteRepository.RPCError.tracebackcCs|jd��S)Nr��r�r?rr+r+r,r�sz)RemoteRepository.RPCError.exception_classcCs.d|jvrd�|jd���S|��dSdS)Nr�rz4
Remote Exception (see remote log for the traceback))r�rCr?r�rr+r+r,�exception_full�s
z(RemoteRepository.RPCError.exception_fullcCs d|jvr|jd��SdSdS)Nr�r�rrr+r+r,r�s
z!RemoteRepository.RPCError.sysinfoN)
r0r1r2rEr��propertyr�rrrr+r+r+r,�RPCError�s


r
c@s(eZdZdZedd��Zedd��ZdS)z"RemoteRepository.RPCServerOutdatedz2Borg server is too old for {}. Required version {}cCs
|jdS�Nr�r�rr+r+r,r�	sz)RemoteRepository.RPCServerOutdated.methodcCs
|jdS)Nrrrr+r+r,�required_version
sz3RemoteRepository.RPCServerOutdated.required_versionN)r0r1r2r3r	r�r
r+r+r+r,r�s

r�FNTc	
s�|�_�_g�_d�_d�_d�_tdt��_d�_	i�_
t��_i�_
i�_d�_t|rl|jrl|jdnd��_|r�|jr�|jddnd�_td��_td��_d�_|�_|jdk}	t|	d�}
��||	�}|	s��|�|}t� d	|�t!|dt"t"t"|
t#d
��_�jj$�%��_&�jj'�%��_(�jj)�%��_*t+�,�j&d�t+�,�j(d�t+�,�j*d��j(�j*g�_-�j&�j(�j*g�_.�zz��/dd
dt0ii�}Wnt1�y�t2d�d�Yn0|t3k�r�d�_4n4t5|t6��r�d|v�r�d�_4|d�_nt7d|���������fdd�}
�j4�r(|
�njz
|
�Wn^�j8�y�}zB|j9dk�rT�d}t:j)�;|�td��_dt<d<|
�WYd}~n
d}~00Wnt7�y���=��Yn0dS)Nrir<iZclientrrZ
__testsuite__)�systemzSSH command line: %s)�bufsizer�r��stderr�envZ
preexec_fnFrfrQr�zIs borg working on the server?sserver_versionTz8Server insisted on using unsupported protocol version %sc	s"�j�jj������d��_dS)N)rRrSrTrUrVrWr�)rg�locationrRrNr+�rWrSrVrUrTr�rFr+r,�do_openKs�z*RemoteRepository.__init__.<locals>.do_openr�aoPlease note:
If you see a TypeError complaining about the number of positional arguments
given to open(), you can ignore it if it comes from a borg version < 1.0.7.
This TypeError is a cosmetic side effect of the compatibility code borg
clients >= 1.0.7 have to support older borg servers.
This problem will go away as soon as the server has been upgraded to 1.0.7+.
z1.0.6)rRrSrTrUrg)>rZ	_location�preload_idsr��rx_bytes�tx_bytesrr�r��stderr_received�chunkid_to_msgidsr��ignore_responses�	responses�async_responses�
shutdown_timer�Zupload_ratelimitr�Z
upload_buffer�upload_buffer_size_limitrr�rr��p�_args�hostr�borg_cmd�ssh_cmdr�r�rrrr�r�r�r�r�rr�r#r��r_fds�x_fdsr�r�r.r4r�r�r�r��	Exceptionr
rr�r$rr�)rFrrSrVrTrUrWr�r��testingrr"�versionr�errr�r+rr,rEs|


�

	
 zRemoteRepository.__init__cCs2t|j�r t�dt|j�f�|jr.|��dS)Nz2still %d cached responses left in RemoteRepository)r"rr�r�rr�rr+r+r,�__del__ks

zRemoteRepository.__del__cCsd|jj�d|j���d�S)N�<r=�>)rHr0rZcanonical_pathrr+r+r,�__repr__rszRemoteRepository.__repr__cCs|Sr�r+rr+r+r,r�uszRemoteRepository.__enter__cCsvzH|dur t��d|_|��Wt�dt|j�t|j�|j	�|�
�n(t�dt|j�t|j�|j	�|�
�0dS)N�zDRemoteRepository: %s bytes sent, %s bytes received, %d messages sent)r%r�rr\r�r�rrrr�r��rF�exc_typeZexc_valZexc_tbr+r+r,�__exit__xs
�
��zRemoteRepository.__exit__cCs
t|j�Sr�)r
rNrr+r+r,�id_str�szRemoteRepository.id_strcCs2g}|dur�t��}|�tj�r,|�d�n^|�tj�rD|�d�nF|�tj�rRn8|�tj�rj|�d�n |�tj�r�|�d�nt	d��|j
D]*}d|vr�d|}d	|vr�|�d
|�q�d|vr�|jr�|�d|j�g}|�r|tj
d
ddg||jS|j�ptj�dd�}t|�}||dg|SdS)z return a borg serve command lineNz--debugz--infoz--errorz
--criticalz log level missing, fix this code�.zborg.debug.rsz--debug-topic=%srvz--storage-quota=%sz-mz
borg.archiverr�ZBORG_REMOTE_PATH�borg)r�r�ZisEnabledForr��append�INFOZWARNINGr��CRITICAL�
ValueErrorZdebug_topicsrvr��
executable�extra_test_args�remote_pathr#�environrar
)rFr�r'ZoptsZroot_loggerZtopicZenv_varsr;r+r+r,r"�s6
zRemoteRepository.borg_cmdcCsl|jjptj�dd�}t�|�}|jr8|dt|j�g7}|j	rX|�
|j	�d|j���n|�
d|j�|S)zEreturn a ssh command line that can be prefixed to a borg command lineZBORG_RSHZsshz-p�@�%s)r �rshr#r<ra�shlex�split�portr��userr5r!)rFrr?r�r+r+r,r#�s
zRemoteRepository.ssh_cmdcs�fdd�t|D�S)Ncsg|]}�|�qSr+r+r��r�r+r,r;�r<z8RemoteRepository.named_to_positional.<locals>.<listcomp>)r)rFr�r�r+rDr,�named_to_positional�sz$RemoteRepository.named_to_positionalcKs&|j||gfi|��D]
}|SdSr���	call_many)rF�cmdr��kw�respr+r+r,r��szRemoteRepository.callc#s(|s|dkrdS�fdd�}�fdd�}�fdd�}t|�}g}	|rHdn�j}
|�|s^|�r�jr�t���jkr�t�d	t|	�t�j��dS|	r�zH�j	�
|	d�}|	�
d�d
|vr�||�n|tV|	s�|s�WdSWq�ty�Yq�Yq�0q�|dk�rbz�j�
�\}}Wn0t�y@|�r6�j�r6Y�qbnYdSYq�0d
|v�rV||�q�|tVq��j�s�|�sx�j�r�t|	�tk�r��jg}
ng}
t��j|
�jd�\}}}|�r�td��|D�]�}|�ju�r�t�|t�}|�s�t���jt|�7_�j�|��jD]�}t|t ��r(|t!}nPt|t"��rpt|�d
k�rp|\}}}}|�rbt!|d
|i}nt!|t|i}nt#|��|�jv�r��j�$|�d
|v�r�|�j|<n|tdu�r�|�j|<n
|�j	|<�qn�|�j%u�r�t�|d�}|�s�t���jt|�7_�j&�r�j&|}d�_&|j'dd�}|�rJ|d�(d��sJ|�
��_&|D]}t)|�*���qN�q�|rTt�j�|
k�r
|�s��j�r
t|	�tk�r
|�rp|�r�|dd�j+v�rp|	�,||�
d�d��n�|�
d�}|dk�r|d�j+v�r|	�,||d��nh�j-d7_-|	�,�j-��j.�rL�j�/t0�1t!�j-t2|t3|i��n$�j�/t0�1d�j-|��4||�f���j�sj�j�rj�j�
d�}d|i}�j-d7_-�j+�5|g��,�j-��j.�r�j�/t0�1t!�j-t2dt3|i��n$�j�/t0�1d�j-d��4d|�f���qj|�qT�jt6|	�O_dS)Nrc
sx�jrtz4�j��j�j���}�j|7_�j�|�Wn8tyr}z |jtj	tj
fvr^�WYd}~n
d}~00dSr�)r�r�r$r�Z
peek_frontrZ	pop_front�OSError�errnoZEAGAINZEWOULDBLOCK)r�r�rr+r,�send_buffer�sz/RemoteRepository.call_many.<locals>.send_buffercs&�j|�d�}�j|s"�j|=|Sr)r�pop)Zchunkidr�rr+r,�pop_preload_msgid�s
z5RemoteRepository.call_many.<locals>.pop_preload_msgidcs||d��}d|v}|�d�}|dkr8t��jj���n@|dkrRt��jj���n&|dkrlt��jj���n|dkr�|r�td��nt|d����n�|d	kr�|r�t�	d��nt�	|d����n�|d
kr�|r�t
d��nt
|d����n�|dk�rt�|d����nr|d
k�rB|�r(t�d�jj��nt�|d���jj��n6|dk�rn|�r\t
d��nt
|d����n
��|��dS)Nr�r�r�r�r�r	z(not available)r�AtticRepositoryr5z	(unknown)�ParentPathDoesNotExistr�r6)r?rarr�rZ	processedr�r�r	rPr5rQr�r6r
)r�r�Z
old_serverr�rr+r,�handle_error�s@






z0RemoteRepository.call_many.<locals>.handle_errorrzPshutdown_time reached, shutting down with %d waiting_for and %d async_responses.r�rzFD exception occurredr}i�r<T)�keepends���)�
rrNra)7r_rrr%r�r�r�r"rrrNr��KeyError�popitemrr�r�MAX_INFLIGHTr�r�r$r%r&r�r#r�r�r.rr�r�r�r�r�r�r8�remover�r�
splitlines�endswith�handle_remote_liner?rr5r�r�Z	push_backrr�r�r�rE�
setdefaultr�)rFrH�callsr��is_preloaded�
async_waitrMrOrRZwaiting_forZmaximum_to_sendr�r�Zw_fdsr�r�r�r'r(r�r�r��lines�liner�Zchunk_idr+rr,rG�s�
)
�






$






,
"$"(zRemoteRepository.call_manyz1.0.0z1.0.7)r�r�z1.1.9)r�rWr�cCsdS�z;actual remoting is done via self.call in the @api decoratorNr+)rFrRrSrTrUrVrWr�r+r+r,rg�szRemoteRepository.openz1.2.0a4r)r��max_durationcCsdSrcr+)rFrJrKrdr+r+r,rZ�szRemoteRepository.checkz1.2.0a0)r�r�r�z1.2.0a8r!)r��compact�	threshold�cleanup_commitscCsdSrcr+)rFrKrerfrgr+r+r,r[�szRemoteRepository.commit)r�cCsdSrcr+rr+r+r,r\�szRemoteRepository.rollbackcCsdSrcr+rr+r+r,r]�szRemoteRepository.destroycCsdSrcr+rr+r+r,r^�szRemoteRepository.__len__cCsdSrcr+�rFrLrMr+r+r,r_�szRemoteRepository.listz1.1.0b3cCsdSrcr+rhr+r+r,rp�szRemoteRepository.scancCs|�|g�D]
}|SdSr�)�get_many)rFrNrJr+r+r,ra�szRemoteRepository.getccs$|jddd�|D�|d�EdHdS)NracSsg|]}d|i�qSrOr+)r:rNr+r+r,r;�r<z-RemoteRepository.get_many.<locals>.<listcomp>)r_rF)rF�idsr_r+r+r,ri�szRemoteRepository.get_manycCsdSrcr+)rFrNr(r�r+r+r,r`�szRemoteRepository.putcCsdSrcr+)rFrNr�r+r+r,rb�szRemoteRepository.deletecCsdSrcr+)rFrPr+r+r,rc�szRemoteRepository.save_keycCsdSrcr+rr+r+r,rd�szRemoteRepository.load_keycCsdSrcr+rr+r+r,rh�szRemoteRepository.get_free_noncecCsdSrcr+)rFrXrYr+r+r,ri�sz)RemoteRepository.commit_nonce_reservationcCsdSrcr+rr+r+r,re�szRemoteRepository.break_lockcCs2|jr.|jj��|jj��|j��d|_dSr�)rr�r�r�r�rr+r+r,r��s

zRemoteRepository.closecCs"|jdgd|d�D]
}|SdS)NrT)r^r�r`rF)rFr�rJr+r+r,�async_response�szRemoteRepository.async_responsecCs|j|7_dSr�)r)rFrjr+r+r,�preload�szRemoteRepository.preload)FFNTFFN)TFT)FNTFFF)FFr)FTr!F)NN)NN)F)T)T)T)+r0r1r2r:r&r
rr�r�rEr*r-r�r1r	r2r"r#rEr�rGrrrgrZr[r\r]r^r_rprarir`rbrcrdrhrirer�rkrlr+r+r+r,r�s�"�
W

.
=����









rcCs�|�d��rFt�|�}|ddvr8t�d|d|�dS|ddkr�tt|dtj�}t�|d�}d	|d
|d
<t�d�jr�||�	�kr�t
j�t�
|�d�n|�|d
|d
�n�|d�d��r�t�d�}|�	�tjk�r�t�d�j�r"d
|v�r
d	|d
|d
<t
j�t�
|�d�n"d
|v�r�t
j�d	|d
d�n�|�d��r�|�dd�\}}}tt|tj�}|�d��r�t�||���n&|�dd�\}}t�|��||���n8t�d�j�r�t�d��d	|���nt
j�d	|�dS)zv
    Handle a remote log line.

    This function is remarkably complex because it handles multiple wire formats.
    �{�type)Zprogress_messageZprogress_percent�log_messagez3Dropped remote log message with unknown type %r: %sNroZ	levelnamerzzRemote: �messager4r�r>Z	progress_zborg.output.progress�
z$LOG r=rzRemote:rr�)r�r��loadsr�Zwarningr�r�r7r�ZgetEffectiveLevelr�rr$�dumpsr�r6rA�rstrip�strip)rbr�r�Z
target_loggerZprogress_loggerr�Zlognamer+r+r,r\�s>



r\c@sLeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	dd�Z
dS)�RepositoryNoCacheaRA not caching Repository wrapper, passes through to repository.

    Just to have same API (including the context manager) as RepositoryCache.

    *transform* is a callable taking two arguments, key and raw repository data.
    The return value is returned from get()/get_many(). By default, the raw
    repository data is returned.
    NcCs||_|pdd�|_dS)NcSs|Sr�r+)�keyr(r+r+r,�<lambda>4r<z,RepositoryNoCache.__init__.<locals>.<lambda>)rs�	transform)rFrsryr+r+r,rE2szRepositoryNoCache.__init__cCsdSr�r+rr+r+r,r�6szRepositoryNoCache.closecCs|Sr�r+rr+r+r,r�9szRepositoryNoCache.__enter__cCs|��dSr�)r�r/r+r+r,r1<szRepositoryNoCache.__exit__cCst|j|gdd��S)NF��cache)�nextri�rFrwr+r+r,ra?szRepositoryNoCache.getTccs.t||j�|��D]\}}|�||�VqdSr�)�ziprsriry)rF�keysr{rwr(r+r+r,riBszRepositoryNoCache.get_manycCsdSr�r+rr+r+r,�log_instrumentationFsz%RepositoryNoCache.log_instrumentation)N)T)r0r1r2r3rEr�r�r1rarir�r+r+r+r,rv)s

rvcs\eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
ddd�Z�ZS)�RepositoryCacheaf
    A caching Repository wrapper.

    Caches Repository GET operations locally.

    *pack* and *unpack* complement *transform* of the base class.
    *pack* receives the output of *transform* and should return bytes,
    which are stored in the cache. *unpack* receives these bytes and
    should return the initial data (as returned by *transform*).
    Ncsvt��||�|pdd�|_|p&dd�|_t�|_tjdd�|_|�	�d|_
d|_d|_d|_
d|_d|_d|_dS)NcSs|Sr�r+�r(r+r+r,rxXr<z*RepositoryCache.__init__.<locals>.<lambda>cSs|Sr�r+r�r+r+r,rxYr<zborg-cache-)�prefixrg)rDrE�pack�unpackr�r{�tempfileZmkdtemp�basedir�query_size_limit�size�hits�misses�slow_misses�slow_lat�	evictions�enospc)rFrsr�r�ryrGr+r,rEVszRepositoryCache.__init__cCs&t�|j�j}tt|dd��|_dS)Ng�?l)�shutil�
disk_usager��freer��min�
size_limit)rFZavailable_spacer+r+r,r�fsz RepositoryCache.query_size_limitcCstj�|jt|��Sr�)r#rRrCr�r
r}r+r+r,�key_filenamejszRepositoryCache.key_filenamecCsn|��td|j�}|j|krj|jrj|j��}|�|�}|jt�|�j	8_t�
|�|jd7_qdS)Ng�������?r)r�r�r�r�r{rNr�r#�stat�st_size�unlinkr�)rFZtarget_sizerw�filer+r+r,�backoffms


zRepositoryCache.backoffc	Cs|�||�}|s|S|�|�}|�|�}z8t|d��}|�|�Wd�n1sT0YWnjty�}zRzt|�Wnty�Yn0|jtj	kr�|j
d7_
|��n�WYd}~n<d}~00|jt
|�7_|j�|�|j|jkr�|��|S)N�wbr)ryr�r�rgr$rKr�FileNotFoundErrorrL�ENOSPCr�r�r�r"r{�addr�)	rFrwr(r{�transformed�packedr�r'Zos_errorr+r+r,�	add_entryws,

,
zRepositoryCache.add_entrycCs>t�dt|j�t|j�t|j�|j|j|j	|j
|j|j�
dS)NzyRepositoryCache: current items %d, size %s / %s, %d hits, %d misses, %d slow misses (+%.1fs), %d evictions, %d ENOSPC hit)
r�r�r"r{rr�r�r�r�r�r�r�r�rr+r+r,r��s
�z#RepositoryCache.log_instrumentationcCs"|��|j��t�|j�dSr�)r�r{�clearr��rmtreer�rr+r+r,r��s
zRepositoryCache.closeTc
	#s$�fdd�|D�}t|�j�|��}|D]�}|�jvr���|�}t|d��.}�jd7_��|���VWd�n1s~0Yq(|D]6\}}	||kr���	||	|�}
�j
d7_
|
Vq(q�t��}�j�
|�}	�jt��|7_��	||	|�}
�jd7_|
Vq(|D]}�qdS)Ncsg|]}|�jvr|�qSr+rz)r:rwrr+r,r;�r<z,RepositoryCache.get_many.<locals>.<listcomp>�rbr)r~rsrir{r�rgr�r�r�r�r�r%�perf_counterrar�r�)
rFrr{Zunknown_keysZrepository_iteratorrwr�r'Zkey_r(r�Zt0r�r+rr,ri�s,

0zRepositoryCache.get_many)NNN)T)
r0r1r2r3rEr�r�r�r�r�r�rirIr+r+rGr,r�Js
r�F)�decrypted_cacher�r�ry�force_cachecs�|r|s|s|rtd��nB|r\|�t�d��td����fdd�}��fdd�}�fdd	�}t|t�sj|rxt||||�St||�Sd
S)a�
    Return a Repository(No)Cache for *repository*.

    If *decrypted_cache* is a key object, then get and get_many will return a tuple
    (csize, plaintext) instead of the actual data in the repository. The cache will
    store decrypted data, which increases CPU efficiency (by avoiding repeatedly decrypting
    and more importantly MAC and ID checking cached objects).
    Internally, objects are compressed with LZ4.
    z:decrypted_cache and pack/unpack/transform are incompatiblez=I8sZlz4cs&|\}}��|�}��|t|��|Sr�)�compressr�r)r(�csize�	decrypted�
compressed��cache_struct�
compressorr+r,r��s
zcache_if_remote.<locals>.packcsPt|�}��|d�j��\}}|�jd�}|t|�krBtd��|��|�fS)Nz)detected corrupted data in metadata cache)�
memoryviewr�r�rr	�
decompress)r(r�Zchecksumr�r�r+r,r��szcache_if_remote.<locals>.unpackcst|�}��||�}||fSr�)r"Zdecrypt)Zid_r(r�r�)rwr+r,ry�sz"cache_if_remote.<locals>.transformN)r8�struct�Structrr�rr�rv)rsr�r�r�ryr�r+)r�r�rwr,�cache_if_remote�s


r�)JrLr�r�r�r�r#r�r@r�r�r�r�rAr%r��
subprocessrrr�rr�rZ	constantsZhelpersrr	r
rrr
rrrrrr�rrrrsrr(rrZalgorithms.checksumsrZhelpers.datastructrr0r�r�r�r�r�r�rXr�r-r.r4r5r6r7r8rrnror�rrr\rvr�r�r+r+r+r,�<module>s�#�y:J!p