403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/hgext/lfs/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/hgext/lfs/__pycache__/blobstore.cpython-39.opt-1.pyc
a

�+�bim�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddl
mZddlmZmZmZmZmZmZmZmZmZddlmZmZdd	lm Z e�!d
�Z"Gdd�dej�Z#Gd
d�de#�Z$Gdd�dej%�Z&Gdd�de'�Z(dd�Z)Gdd�dej*j+�Z,Gdd�de'�Z-Gdd�de'�Z.Gdd�de'�Z/Gdd�de'�Z0e-e-e.e/e0d�Z1d d!�Z2d"d#�Z3d*d$d%�Z4Gd&d'�d'ej5�Z6Gd(d)�d)ej7�Z8dS)+�)�absolute_importN)�_)�getattr)�hex)	�encoding�error�httpconnection�pathutil�pycompat�url�util�vfs�worker)�
stringutil�urlutil�)�lfutils\A[a-f0-9]{64}\Zcs&eZdZ�fdd�Zddd�Z�ZS)�lfsvfscs:t�|�st�d|��tt|��|dd�|dd��S)z9split the path at first two characters, like: XX/XXXXX...sunexpected lfs path: %srrN)�_lfsre�matchr�ProgrammingError�superr�join)�self�path��	__class__��9/usr/lib64/python3.9/site-packages/hgext/lfs/blobstore.pyr.s
zlfsvfs.joinNc#s�tj�|j�}tt�|��}g}tj|�|j|p2d�|d�D]:\�}}�|d��t��dkr<|�	�fdd�|D��q<dg|fVdS)z�Yield (dirpath, [], oids) tuple for blobs under path

        Oids only exist in the root of this vfs, so dirpath is always ''.
        �)�onerrorNrcs"g|]}t��|�r�|�qSr)rr)�.0�f��dirpathrr�
<listcomp>Grzlfsvfs.walk.<locals>.<listcomp>)
�osr�normpath�base�lenr	Znormasprefix�walkZreljoin�extend)rrr �rootZ	prefixlen�oids�dirs�filesrr#rr*4s��zlfsvfs.walk)NN)�__name__�
__module__�__qualname__rr*�
__classcell__rrrrr-src@s6eZdZdd�Zdd�Zdd�Zddd	�Zd
d�ZdS)
�nullvfscCsdS�Nr�rrrr�__init__Nsznullvfs.__init__cCsdS)NFr�r�oidrrr�existsQsznullvfs.existscCsttjt�d|���dS)Ns%s: No such file or directory)�IOError�errno�ENOENTr
Zsysstrr8rrr�readTs�znullvfs.readNcCs
dggfS)Nrr)rrr rrrr*^sznullvfs.walkcCsdSr5r)rr9�datarrr�writeasz
nullvfs.write)NN)r0r1r2r7r:r>r*r@rrrrr4Ms


r4cs(eZdZdZ�fdd�Zdd�Z�ZS)�
lfsuploadfilez+a file-like object that supports keepalive.cs"tt|��||d�|jj|_dS�Nsrb)rrAr7�_datar>)r�ui�filenamerrrr7hszlfsuploadfile.__init__cCsdSr5rr6rrr�
_makeprogresslszlfsuploadfile._makeprogress)r0r1r2�__doc__r7rFr3rrrrrAesrAc@sjeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�ZdS)�localz�Local blobstore for large file contents.

    This blobstore is used both as a cache and as a staging area for large blobs
    to be uploaded to the remote blobstore.
    cCsR|j�d�}t|�|_|j�dd�r.t�|_nt�	|jd�}t|�|_|j|_dS)Nslfs/objects�experimentalslfs.disableusercache�lfs)
Zsvfsrrr
rD�
configboolr4�cachevfsrZ
_usercachedir)r�repo�fullpathZ	usercacherrrr7ws


zlocal.__init__cCst|�|�d�S)zgOpen a read-only file descriptor to the named blob, in either the
        usercache or the local store.�rb)�openrr8rrrrP�sz
local.opencCs$|j�|�r|j�|�S|j�|�S)a{Build the path for the given blob ``oid``.

        If the blob exists locally, the path may point to either the usercache
        or the local store.  If it doesn't, it will point to the local store.
        This is meant for situations where existing code that isn't LFS aware
        needs to open a blob.  Generally, prefer the ``open`` method on this
        class.
        )rLr:rr
r8rrrr�sz
local.pathc
Cs�t��}d}|j|ddd���}tj|dd�D]$}|�|�|�|�|t|�7}q,|dur�t|�|kr�d}t	t
|�|t|�f��t|���}	|	|kr�t
t
d	�|��Wd�n1s�0Y|�|�dS)
znRead the blob from the remote source in chunks, verify the content,
        and write to this local blobstore.r�wbT�Z
atomictemp���sizeNsXResponse length (%s) does not match Content-Length header (%d): likely server-side crashscorrupt remote lfs object: %s)�hashlib�sha256r
r�
filechunkiterr@�updater)�int�LfsRemoteErrorrr�digest�LfsCorruptionError�_linktousercache)
rr9�srcZcontent_lengthrWrU�fp�chunk�msg�realoidrrr�download�s"

�
�"zlocal.downloadcCsH|j|ddd��}|�|�Wd�n1s00Y|�|�dS)z�Write blob to local blobstore.

        This should only be called from the filelog during a commit or similar.
        As such, there is no need to verify the data.  Imports from a remote
        store must use ``download()`` instead.rQTrRN)r
r@r^)rr9r?r`rrrr@�s(zlocal.writecCsLt|jt�sH|j�|�sH|j�td�|�t�	|j�
|�|j�
|��dS)a�Link blobs found in the user cache into this store.

        The server module needs to do this when it lets the client know not to
        upload the blob, to ensure it is always available in this store.
        Normally this is done implicitly when the client reads or writes the
        blob, but that doesn't happen when the server tells the client that it
        already has the blob.
        �lfs: found %s in the usercache
N)�
isinstancerLr4r
r:rD�noterr�linkrr8rrr�linkfromusercache�s	zlocal.linkfromusercachecCsL|j�|�sHt|jt�sH|j�td�|�t�|j	�
|�|j�
|��dS)Ns lfs: adding %s to the usercache
)rLr:rfr4rDrgrrrhr
rr8rrrr^�s
�zlocal._linktousercacheTcCs�|j�|�sh|�|j||�}|s6tt�|����|kr�|j�	t
d�|�t�|j�
|�|j�
|��n$|j�	t
d�|�|�|j||�}|S)zRead blob from local blobstore.res%lfs: found %s in the local lfs store
)r
r:�_readrLrrVrWr\rDrgrrrhr)rr9�verify�blobrrrr>�sz
local.readcCs|�|�}|rt||�|S)z0Read blob (after verifying) from the given store)r>�_verify)rr
r9rkrlrrrrj�s

zlocal._readcCs`t��}|�|��.}tj|dd�D]}|�|�q"Wd�n1sF0Y|t|���kS)zQIndicate whether or not the hash of the underlying file matches its
        name.rSrTN)rVrWrPrrXrYrr\)rr9rWr`rarrrrk�s
*zlocal.verifycCs|j�|�p|j�|�S)zYReturns True if the local blobstore contains the requested blob,
        False otherwise.)rLr:r
r8rrr�hassz	local.hasN)T)r0r1r2rGr7rPrrdr@rir^r>rjrkrnrrrrrHps 
	
rHc	Cs�|}t|jt�r|j}t�|d�rjz|jjd}WnttfyN|j}Yn0t|tj	�rft
�|�}|St|dd�r�t
�
|j�St�|�SdS)zbCreate a friendly message for the given URLError to be used in an
    LfsRemoteError message.
    sreason��strerrorN)rf�reason�	Exceptionr�safehasattr�args�AttributeError�
IndexErrorr
�unicoderZ
unitolocalrZ
strtolocalrpr�forcebytestr)�urlerror�instrqrrr�_urlerrorreasons
r{c@seZdZdZdd�ZdS)�lfsauthhandleri�cCsR|�dd�}|rN|��d}|��dkrNtd�}tj�|��|t�	|�||��dS)z�Enforces that any authentication performed is HTTP Basic
        Authentication.  No authentication is also acceptable.
        zwww-authenticateNrZbasics,the server must support Basic Authentication)
�get�split�lowerrr�urlerr�	httperrorZget_full_urlrZstrfromlocal)rZreqr`�coderb�headersZauthreq�schemerrr�http_error_401"s�zlfsauthhandler.http_error_401N)r0r1r2Z
handler_orderr�rrrrr|sr|c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
_gitlfsremotecCsr|j}||_|��\}}|�d�|_|j�dd�}|sBdt��}t�|||�|_	|j	�
t��|�dd�|_
dS)N�/rIslfs.user-agentsgit-lfs/2.3.4 (Mercurial %s)rJsretry)rD�authinfo�rstrip�baseurl�configr�version�urlmod�opener�	urlopenerZadd_handlerr|Z	configint�retry)rrMrrDr�r�Z	useragentrrrr77sz_gitlfsremote.__init__cCs|�t|�|d�dS)z,Batch upload from local to remote blobstore.�uploadN��_batch�_deduplicate�r�pointers�	fromstorerrr�
writebatchCsz_gitlfsremote.writebatchcCs|�t|�|d�dS)z-Batch download from remote to local blostore.�downloadNr��rr��tostorerrr�	readbatchGsz_gitlfsremote.readbatchcCsPdd�|D�}t�t�|t�|�d���}d|j}tjjt�|�|d�}|�	dd�|�	dd�z>t
�|j�
|���}|��}Wd	�n1s�0YWn�tjj�y }	zbtd
�|j|ftd�|jd�}
|
�|	jtd
�||f�}ttd�t�|	�|d��WYd	}	~	nXd	}	~	0tjj�yn}	z2td�|j}ttd�t|	�|d��WYd	}	~	n
d	}	~	00zt�|�}Wn*t�y�ttd�|�d���Yn0|jj�r<|j�d|j�t� |�!���"�}
|j�dd�#t$|
�%����d|v�rt$|ddd�d�|d<|j�dt�tj|dddd���dd�}t�&||�S) z�Get metadata about objects pointed by pointers for given action

        Return decoded JSON object like {'objects': [{'oid': '', 'size': 1}]}
        See https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md
        cSs$g|]}t�|���|��d��qS))r9rU)r
�strurlr9rU�r!�prrrr%Qs�z/_gitlfsremote._batchrequest.<locals>.<listcomp>)�objectsZ	operations%s/objects/batch)r?ZAcceptzapplication/vnd.git-lfs+json�Content-TypeNs=check that lfs serving is enabled on %s and "%s" is supporteds/the "lfs.url" config may be used to override %s)i��sapi=%s, action=%ssLFS HTTP error: %s��hint�
LFS error: %ss#LFS server returns invalid JSON: %s�utf-8�Status: %d
�%s
�
r�cSs|dS)Nr9r)r�rrr�<lambda>�rz-_gitlfsremote._batchrequest.<locals>.<lambda>��keyr)�z: T)�indentZ
separatorsZ	sort_keyscSst|tj�r|�d�S|S)Nr�)rfr
rw�encode)�xrrr�	encodestr�s
z._gitlfsremote._batchrequest.<locals>.encodestr)'r
�bytesurl�json�dumpsr�r�r�urlreq�request�
add_header�
contextlib�closingr�rPr>r�r�rr}r�r[rrxryr{Z
json_loads�
ValueErrorr�rD�	debugflag�debug�status�bytestr�info�stripr�sorted�
splitlinesZrapply)rr��actionr�ZrequestdatarZbatchreqZrspZrawjson�ex�hintsr��responser�r�rrr�
_batchrequestKs�����
*����	������


�
����z_gitlfsremote._batchrequestcCs�|D]�}d|vr2|dkr||�dg�vrd}qDqn|�d��dd�}dd�|D�}|�|d	d
�}|r�t|dd�}d
dddd�}	|	�|d|�}
ttd�||
f��qttd�|d	��qd
S)zUScans errors from objects

        Raises LfsRemoteError if any objects have an errorserrorr��actionsr�scode��cSsi|]}|��|�qSr)r9r�rrr�
<dictcomp>�rz6_gitlfsremote._checkforservererror.<locals>.<dictcomp>�oidNrEsunknownsThe object does not exists#The object was removed by the ownersValidation errorsInternal server error)r�i�i�r�sstatus code %dsLFS server error for "%s": %ss1LFS server error. Unsolicited response for oid %s)r}rr[r)rr�Z	responsesr�r�r�Zptrmapr�rE�errorsrbrrr�_checkforservererror�s4�����z"_gitlfsremote._checkforservererrorcs0|�dg�}|�||���fdd�|D�}|S)z�extract objects from response of the batch API

        response: parsed JSON object returned by batch API
        return response['objects'] filtered by action
        raise if any object has an error
        sobjectscs g|]}�|�dg�vr|�qS)r��r})r!�o�r�rrr%�sz1_gitlfsremote._extractobjects.<locals>.<listcomp>)r}r�)rr�r�r�r�Zfilteredobjectsrr�r�_extractobjects�s
�z_gitlfsremote._extractobjectsc
Cs�|d}|d|�d�}|d|�di���}tj�t�|��}|dkrp|�|�sptj	t
d�|t
d�d��|D] \}}	|�t�|�t�|	��qt�z�z8|dkr�t|j
|�|��|_d	d
�|_|�dd�|�d
|jj�t�|j�|����}
|
���d�}|j
}|j
j�rP|�d|
j�t�|
�����}|�dd�t|�����|dk�rj|�||
|�nHg}
|
� d�}|�s��q�|
�!|��qnd�|
�}|�r�|�d||f�Wd�n1�s�0YWn�tj"j#�y<}zJ|j
j�r|j
�d||� �f�t$t
d�t%�&|�||f��WYd}~ndd}~0tj"j'�y�}z>t
d�t�(tj)�*|��}t$t
d�t+|�|d��WYd}~n
d}~00W|j�r�|j�,�n|j�r�|j�,�0dS)aCDownload or upload a single object using basic transfer protocol

        obj: dict, an object description returned by batch API
        action: string, one of ['upload', 'download']
        localstore: blobstore.local

        See https://github.com/git-lfs/git-lfs/blob/master/docs/api/        basic-transfers.md
        r�r�shrefsheaderr��detected corrupt lfs object: %s�
run hg verifyr�cSsdS)NZPUTrrrrrr��rz._gitlfsremote._basictransfer.<locals>.<lambda>r�zapplication/octet-streamzContent-Lengthscontent-lengthr�r�r�r�rSrslfs %s response: %sNs%s: %s
s&LFS HTTP error: %s (oid=%s, action=%s)sattempted connection to %sr�)-r}�itemsrr�r�r
r�rkr�Abortrr�rArDrr?Z
get_method�lengthr�r�r�rPr�r�r�r�r�r�rr�r�rdr>�appendr�r�r[rrxryr�ZurllibcompatZ
getfullurlr{�close)r�objr��
localstorer9Zhrefr�r��k�v�resZ
contentlengthrDZblocksr?r�r�r�rrr�_basictransfer�sp


�




6
���

���z_gitlfsremote._basictransferc
s��dvrt�d�����|��}��||��}tdd�|D��}i}|D]}|�dd�||�d�<qJtd�td	�d��}	t|�d
kr��j�	td�t|�t
�|�f����fdd
�}
�j�dd�r�t
�
�jd|
dt|dd�d��}n|
t|dd�d��}�jj|	td�|d��d}|�d�d}
d}|D]<\}}|
||7}
|d
7}|�|
��j�	td�|��q,Wd�n1�s�0Y|dk�r�dk�r��j�td�|t
�|
�f�n(�dk�r�j�td�|t
�|
�f�dS)N)r�r�sinvalid Git-LFS action: %scss|]}|�dd�VqdS)�sizerNr�)r!r�rrr�	<genexpr>0rz'_gitlfsremote._batch.<locals>.<genexpr>r�rr�s
lfs uploadingslfs downloadingros&lfs: need to transfer %d objects (%s)
c3s�|D]�}|�dd�}�jjr^�dkr.td�}n�dkr>td�}�j�||�d�t�|�f��j}z&��|���d|�d�fVWqWqdt	j
y�}zH|dkrֈj�td	�t�|�|f�|d8}WYd}~qd�WYd}~qdd}~00qdqdS)
Nr�rr�slfs: downloading %s (%s)
r�slfs: uploading %s (%s)
r�ros%lfs: failed: %r (remaining retry %d)
)
r}rD�verboserrgr�	bytecountr�r��socketrrrx)rar�Zobjsizerbr�r��r�r�rrr�transfer>s2
���z&_gitlfsremote._batch.<locals>.transferrIslfs.worker-enableg�������?rcSs
|�d�S�Nr�r��r�rrrr�`rz&_gitlfsremote._batch.<locals>.<lambda>r�cSs
|�d�Sr�r�r�rrrr�crsbytes)Zunit�totalslfs: processed: %s
r�slfs: uploaded %d files (%s)
r�slfs: downloaded %d files (%s)
)rrr�r��sumr}rr)rDrgrr�rKrr�ZmakeprogressrYr�)rr�r�r�r�r�r�Zsizesr�Ztopicr�r-ZprogressZ	processedZblobsZ_oner9rr�rr�*sl�����
�

8

��
��z_gitlfsremote._batchcCs:t|dd�}|r6|jD]}|��t|ddd���qdS)Nr�Z	close_allcSsdSr5rrrrrr��rz'_gitlfsremote.__del__.<locals>.<lambda>)r�handlersr�)rr��hrrr�__del__}s

z_gitlfsremote.__del__N)r0r1r2r7r�r�r�r�r�r�r�r�rrrrr�6sU)NSr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_dummyremotez,Dummy store storing blobs to temp directory.cCs|j�d|j�}t|�|_dS)NrJ)r
rrr)rrMrrNrrrr7�sz_dummyremote.__init__c	Csbt|�D]T}|j|��dd�}|j|��ddd��}|�|�Wd�q1sR0YqdS)NT)rkrQrR)r�r>r9r
r@)rr�r�r��contentr`rrrr��sz_dummyremote.writebatchc	CsTt|�D]F}|�|��d��"}|�|��|d�Wd�q1sD0YqdSrB)r�r
r9rd)rr�r�r�r`rrrr��sz_dummyremote.readbatchN�r0r1r2rGr7r�r�rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_nullremotez&Null store storing blobs to /dev/null.cCsdSr5r�rrMrrrrr7�sz_nullremote.__init__cCsdSr5rr�rrrr��sz_nullremote.writebatchcCsdSr5rr�rrrr��sz_nullremote.readbatchNr�rrrrr��sr�c@s4eZdZdZdd�Zddd�Zddd�Zd	d
�ZdS)
�
_promptremotez)Prompt user to set lfs.url when accessed.cCsdSr5rr�rrrr7�sz_promptremote.__init__NcCs|��dSr5��_prompt)rr�r�rDrrrr��sz_promptremote.writebatchcCs|��dSr5r�)rr�r�rDrrrr��sz_promptremote.readbatchcCst�td���dS)Nslfs.url needs to be configured)rr�rr6rrrr��sz_promptremote._prompt)N)N)r0r1r2rGr7r�r�r�rrrrr��s


r�)�https�httpsfilesnullNcCs&t��}|D]}|||��<q|��S)z0Remove any duplicate oids that exist in the list)rZsortdictr9�values)r�Zreducedr�rrrr��sr�cCs6tt�|����}||kr2ttd�|td�d��dS)Nr�r�r�)rrVrWr\r]r)r9r�rcrrrrm�s
�rmcCs�|j�dd�}t�|pd�}|dur�|r.|}n&t�|d�rB|j}n|j�dd�pRd}t�|�}|jdvr�|jr�|jdd	�d
kr�|jd
7_|jp�dd|_t�t	|��}|j�
td�|�|j}|tvr�t
�td
�|��t|||�S)a�remotestore factory. return a store in _storemap depending on config

    If ``lfs.url`` is specified, use that remote endpoint.  Otherwise, try to
    infer the endpoint, based on the remote repository using the same path
    adjustments as git.  As an extension, 'http' is supported as well so that
    ``hg serve`` works out of the box.

    https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md
    rJsurlrNs_subtoppathspathssdefault)r�r����r�s
.git/info/lfsslfs: assuming remote store: %s
slfs: unknown url scheme: %s)rDr�rrrrsZ_subtoppathr�r�bytesrgr�	_storemaprr�)rM�remoteZlfsurlrrZ
defaulturlr�rrrr��s&


r�c@seZdZdS)r[N)r0r1r2rrrrr[�sr[c@seZdZdZdS)r]z~Raised when a corrupt blob is detected, aborting an operation

    It exists to allow specialized handling on the server side.N)r0r1r2rGrrrrr]�sr])N)9Z
__future__rr�r<rVr�r&�rer�Zmercurial.i18nrZmercurial.pycompatrZmercurial.noderZ	mercurialrrrZhttpconnectionmodr	r
rr�rr
ZvfsmodrZmercurial.utilsrrZ
largefilesr�compilerrr4ZhttpsendfilerA�objectrHr{r�Zbasehandlerr|r�r�r�r�r�r�rmr�ZStorageErrorr[r�r]rrrr�<module>sL,
 R
�		
+

Youez - 2016 - github.com/yon3zu
LinuXploit