Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
lib
/
python3
/
dist-packages
/
duplicity
/
backends
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: par2backend.cpython-310.pyc
o �xa;$ � @ sn d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZ G dd� dej �Z e�d e � dS ) � N)�backend)�BackendException)�log)�config)�utilc @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� ZdS )�Par2Backendz�This backend wrap around other backends and create Par2 recovery files before the file and the Par2 files are transfered with the wrapped backend. If a received file is corrupt it will try to repair it on the fly. c C s� t j�| |� zdd laW n ty � w || _ztj| _W n t y+ d| _Y nw ztj | _W n t y> d| _Y nw ztjd | _ W n t yS d| _ Y nw t �|j�| _dD ]}t| j|�rrt| |t| |dd � �� q]| j| _d S )Nr � � z -q -qz-q -q)�_get�_put�_list�_delete�_delete_list�_query�_query_list�_retry_cleanup�_error_code�_move�_close)r �Backend�__init__�pexpect�ImportError� parsed_urlr �par2_redundancy� redundancy�AttributeError�par2_volumes�volumes�par2_options�common_options�get_backend_object� url_string�wrapped_backend�hasattr�setattr�getattr�delete_listr )�selfr �attr� r* �@/usr/lib/python3/dist-packages/duplicity/backends/par2backend.pyr $ s8 � � � ��zPar2Backend.__init__c C sP |� � }|�� |�|�}|�� }tj�|�s#tj�t� t� � �|�}t�||�� � |�� t �d� d| j| j| jt�|�� �f }t�|dd�\}} | rrt �d� d| j| jt�|�� �f }t�|dd�\}} | srt �d� |�� g } | s�|�� D ] }| �|�|�� q~nt �d| � |||� | D ] }|||�� � q�|�� dS ) a3 create Par2 files and transfer the given file and the Par2 files with the wrapped backend. Par2 must run on the real filename or it would restore the temp-filename later on. So first of all create a tempdir and symlink the soure_path with remote_filename into this. zCreate Par2 recovery fileszpar2 c -r%d -n%d %s "%s"NTzDFailed to create par2 file with requested options, retrying with -n1zpar2 c -r%d -n1 %s "%s"z'Successfully created par2 file with -n1z-FAILED to create par2 file with returncode %d)�get_temp_in_same_dir�mkdir�append� get_canonical�os�path�isabs�joinr �fsencode�getcwd�symlink�setdatar �Infor r r �fsdecoder �run�Warn�delete�listdir�Error�get_filename�deltree)r( �method�source_path�remote_filename�par2temp�source_symlink� source_target� par2create�out� returncode�files_to_transfer�filer* r* r+ �transferI sB � � � zPar2Backend.transferc C � | � | jj||� d S �N)rL r# r �r( �local�remoter* r* r+ �putv � zPar2Backend.putc C rM rN )rL r# r rO r* r* r+ �movey rS zPar2Backend.movec s� |� � }|�� |�|�}| j�||� z�z�|�|d �}| j�|�� |� d| jt�|� � �t�|� � �f }t �|dd�\}}|r�t� d| � t�d|�� �� � fdd�| j�� D �} | D ]} |�| �}| j�| |� qad | jt�|� � �t�|� � �f }t �|dd�\}}|r�t�d | � nt� d| � W n ty� Y n w W |�|� |�� dS W |�|� |�� dS |�|� |�� w )a transfer remote_filename and the related .par2 file into a temp-dir. remote_filename will be renamed into local_path before finishing. If "par2 verify" detect an error transfer the Par2-volumes into the temp-dir and try to repair. s .par2zpar2 v %s %s "%s"NTz!File is corrupt. Try to repair %sz%s\.vol[\d+]*\.par2c s g | ]}� � t�|��r|�qS r* )�matchr r9 )�.0�f��cr* r+ � <listcomp>� s z#Par2Backend.get.<locals>.<listcomp>zpar2 r %s %s "%s"zFailed to repair %szRepair successful %s)r, r- r. r# r r? r r r9 r/ r r: r r; �re�compile�decoder r>