HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/awscli/customizations/s3/__pycache__/comparator.cpython-310.pyc
o

.&�a:�@s2ddlZddlmZe�e�ZGdd�de�ZdS)�N)�advance_iteratorc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
ComparatorzN
    This class performs all of the comparisons behind the sync operation
    cCs||_||_||_dS)N)�_sync_strategy�_not_at_dest_sync_strategy�_not_at_src_sync_strategy)�self�"file_at_src_and_dest_sync_strategy�file_not_at_dest_sync_strategy�file_not_at_src_sync_strategy�r�E/usr/lib/python3/dist-packages/awscli/customizations/s3/comparator.py�__init__s
zComparator.__init__ccsX�d}d}d}d}	z
|s|rt|�}Wn
ty!d}d}Ynwz
|s+|r+t|�}Wn
ty9d}d}Ynw|s�|s�d}d}|�||�}	|	dkrY|j�||�}
|
rX|VnR|	dkrnd}d}|j�|d�}
|
rm|Vn=|	dkr�d}d}|j�d|�}
|
r�|Vn(|s�|r�d}|j�|d�}
|
r�|Vn|r�|s�d}|j�d|�}
|
r�|VndSq
)a�
        This function preforms the actual comparisons.  The parameters it takes
        are the generated files for both the source and the destination.  The
        key concept in this function is that no matter the type of where the
        files are coming from, they are listed in the same order, least to
        greatest in collation order.  This allows for easy comparisons to
        determine if file needs to be added or deleted.  Comparison keys are
        used to determine if two files are the same and each file has a
        unique comparison key.  If they are the same compare the size and
        last modified times to see if a file needs to be updated.   Ultimately,
        it will yield a sequence of file info objectsthat will be sent to
        the ``S3Handler``.

        :param src_files: The generated FileInfo objects from the source.
        :param dest_files: The generated FileInfo objects from the dest.

        :returns: Yields the FilInfo objects of the files that need to be
            operated on

        Algorithm:
            Try to take next from both files. If it is empty signal
            corresponding done flag.  If both generated lists are not done
            compare compare_keys.  If equal, compare size and time to see if
            it needs to be updated.  If source compare_key is less than dest
            compare_key, the file needs to be added to the destination.  Take
            the next source file but not not destination file.  If the source
            compare_key is greater than dest compare_key, that destination file
            needs to be deleted from the destination.  Take the next dest file
            but not the source file.  If the source list is empty delete the
            rest of the files in the dest list from the destination.  If the
            dest list is empty add the rest of the file in source list to
            the destination.
        FTN�equal�	less_than�greater_than)r�
StopIteration�compare_comp_keyr�determine_should_syncrr)r�	src_files�
dest_files�src_done�	dest_done�src_take�	dest_take�src_file�	dest_file�compare_keys�should_syncrrr�call sz�#�����������zComparator.callcCs(|j}|j}||krdS||krdSdS)z�
        Determines if the source compare_key is less than, equal to,
        or greater than the destination compare_key
        rrr)�compare_key)rrr�src_comp_key�
dest_comp_keyrrrr�szComparator.compare_comp_keyN)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrs
br)�logging�
awscli.compatr�	getLoggerr"�LOG�objectrrrrr�<module>s