o y`Z4@sddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z Gd d d eZ Gd d d eZ GdddeZdS)N)Task)SubmissionTask)CreateMultipartUploadTask)CompleteMultipartUploadTask) get_callbacks)calculate_range_parameter)get_filtered_dict)ChunksizeAdjusterc @sxeZdZdZdddddddd d d Zgd Zgd Zd d gZddZddZ ddZ ddZ ddZ ddZ ddZdS)CopySubmissionTaskz+Task for submitting tasks to execute a copyIfMatchIfModifiedSince IfNoneMatchIfUnmodifiedSinceSSECustomerKeySSECustomerAlgorithmSSECustomerKeyMD5 RequestPayerExpectedBucketOwner) CopySourceIfMatchCopySourceIfModifiedSinceCopySourceIfNoneMatchCopySourceIfUnmodifiedSinceCopySourceSSECustomerKeyCopySourceSSECustomerAlgorithmCopySourceSSECustomerKeyMD5rr) rrrrrrrrrrrr) rrrrrrrMetadataDirectiveTaggingDirectivec Cs|jjdur9|jj}||j}|j}|D]\} } | |jvr'| ||j| <q|jj di|} |j | d|jj|j krK| |||||dS| |||||dS)a :param client: The client associated with the transfer manager :type config: s3transfer.manager.TransferConfig :param config: The transfer config associated with the transfer manager :type osutil: s3transfer.utils.OSUtil :param osutil: The os utility associated to the transfer manager :type request_executor: s3transfer.futures.BoundedExecutor :param request_executor: The request executor associated with the transfer manager :type transfer_future: s3transfer.futures.TransferFuture :param transfer_future: The transfer future associated with the transfer request that tasks are being submitted for N ContentLength)metasize call_args)_get_head_object_request_from_copy_source copy_source extra_argsitemsEXTRA_ARGS_TO_HEAD_ARGS_MAPPING source_client head_objectprovide_transfer_sizemultipart_threshold_submit_copy_request_submit_multipart_request) selfclientconfigosutilrequest_executortransfer_futurer!head_object_requestr$paramvalueresponserr3/usr/lib/python3/dist-packages/s3transfer/copies.py_submitIs6     zCopySubmissionTask._submitc CsL|jj}t|d}|j|t|j||j|j|j|j ||jj ddddS)Nprogress)r.r#bucketkeyr$ callbacksr T)transfer_coordinator main_kwargsis_final) rr!r_transfer_coordinatorsubmitCopyObjectTaskr#r:r;r$r )r-r.r/r0r1r2r!progress_callbacksrrr7r+s"  z'CopySubmissionTask._submit_copy_requestcCsj|jj}i}|jD] \}} ||jvr| ||<q |j|t|j||j|j |dd} |j } t } | | |jj } tt|jj t| } g}t|d}td| dD]?}||j}t| |d| |jj |d<|| |d| |jj }||j|t|j||j|j|j ||||dd| idqU||j}|j|t|j||j|j |d| |d d d dS) N)r.r:r;r$)r=r>r9CopySourceRange)r.r#r:r; part_numberr$r<r upload_id)r=r>pending_main_kwargs)rGpartsT)r=r>rHr?)rr!r$r%CREATE_MULTIPART_ARGS_BLACKLISTr@rArr:r;multipart_chunksizer adjust_chunksizer intmathceilfloatrrange_extra_upload_part_argsr_get_transfer_sizeappend CopyPartTaskr#_extra_complete_multipart_argsr)r-r.r/r0r1r2r!create_multipart_extra_argsr4valcreate_multipart_future part_sizeadjuster num_parts part_futuresrCrFextra_part_argsr complete_multipart_extra_argsrrr7r,s   z,CopySubmissionTask._submit_multipart_requestcCs(t|tr t|Std|t|f)NzZExpecting dictionary formatted: {"Bucket": bucket_name, "Key": key} but got %s or type %s.) isinstancedictcopy TypeErrortype)r-r#rrr7r"s   zs         x