
    3                         S SK r S SKrS SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S S	KJr   " S
 S\5      r " S S\5      r " S S\5      rg)    N)Task)SubmissionTask)CreateMultipartUploadTask)CompleteMultipartUploadTask)get_callbacks)calculate_range_parameter)get_filtered_dict)ChunksizeAdjusterc            	       n    \ rS rSrSrSSSSSSS	S
S.r/ SQr/ SQrS
/rS r	S r
S rS rS rS rS rSrg)CopySubmissionTask   z+Task for submitting tasks to execute a copyIfMatchIfModifiedSinceIfNoneMatchIfUnmodifiedSinceSSECustomerKeySSECustomerAlgorithmSSECustomerKeyMD5RequestPayer)CopySourceIfMatchCopySourceIfModifiedSinceCopySourceIfNoneMatchCopySourceIfUnmodifiedSinceCopySourceSSECustomerKeyCopySourceSSECustomerAlgorithmCopySourceSSECustomerKeyMD5r   )r   r   r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   MetadataDirectiveTaggingDirectivec                 .   UR                   R                  c  UR                   R                  nU R                  UR                  5      nUR
                  nUR                  5        H(  u  pXR                  ;   d  M  U
UU R                  U	   '   M*     UR                  R                  " S0 UD6nUR                   R                  US   5        UR                   R                  UR                  :  a  U R                  XX4U5        gU R                  XX4U5        g)aj  
: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 )metasize	call_args)_get_head_object_request_from_copy_sourcecopy_source
extra_argsitemsEXTRA_ARGS_TO_HEAD_ARGS_MAPPINGsource_clienthead_objectprovide_transfer_sizemultipart_threshold_submit_copy_request_submit_multipart_request)selfclientconfigosutilrequest_executortransfer_futurer$   head_object_requestr'   paramvalueresponses               $lib/third_party/s3transfer/copies.py_submitCopySubmissionTask._submitF   s   * $$, (,,66I>>))+   #--J !+ 0 0 2@@@GL (<<UCE !3
 !..:: '%'H  66)+
 $$v'A'AA%%/K **/K    c                 .   UR                   R                  n[        US5      nU R                  R	                  U[        U R                  UUR                  UR                  UR                  UR                  UUR                   R                  S.SS95        g )Nprogress)r1   r&   bucketkeyr'   	callbacksr#   T)transfer_coordinatormain_kwargsis_final)r"   r$   r   _transfer_coordinatorsubmitCopyObjectTaskr&   r@   rA   r'   r#   )r0   r1   r2   r3   r4   r5   r$   progress_callbackss           r:   r.   'CopySubmissionTask._submit_copy_request|   s    #((22	 +?JG 	""))%)%?%?$#,#8#8'..$=="+"6"6!3+0055 	
r=   c                    UR                   R                  n0 nUR                  R                  5        H  u  pXR                  ;  d  M  XU'   M     U R
                  R                  U[        U R
                  UUR                  UR                  US.S95      n
UR                  n[        5       nUR                  XR                   R                  5      n[        [        R                   " UR                   R                  [#        U5      -  5      5      n/ n[%        US5      n['        SUS-   5       H  nU R)                  UR                  5      n[+        UUS-
  XR                   R                  5      US'   U R-                  UUS-
  XR                   R                  5      nUR/                  U R
                  R                  U[1        U R
                  UUR2                  UR                  UR                  UUUUS.SU
0S95      5        M     U R5                  UR                  5      nU R
                  R                  U[7        U R
                  UUR                  UR                  US.U
US	.S
S95        g )N)r1   r@   rA   r'   )rC   rD   r?      CopySourceRange)r1   r&   r@   rA   part_numberr'   rB   r#   	upload_id)rC   rD   pending_main_kwargs)rO   partsT)rC   rD   rP   rE   )r"   r$   r'   r(   CREATE_MULTIPART_ARGS_BLACKLISTrF   rG   r   r@   rA   multipart_chunksizer
   adjust_chunksizer#   intmathceilfloatr   range_extra_upload_part_argsr   _get_transfer_sizeappendCopyPartTaskr&   _extra_complete_multipart_argsr   )r0   r1   r2   r3   r4   r5   r$   create_multipart_extra_argsr7   valcreate_multipart_future	part_sizeadjuster	num_partspart_futuresrI   rN   extra_part_argsr#   complete_multipart_extra_argss                       r:   r/   ,CopySubmissionTask._submit_multipart_request   so   #((22	 ')##..446JE@@@58E2 7 #'"<"<"C"C%%)%?%?$'..$=="=	#
 ..	$&--++002	IIo**//%	2BBCE	 *?JG IM2K"::$$&O
 2K;q=)5I5I5N5N2PO-. **;q=)5I5I5N5ND **11$ -1-G-G&,+4+@+@&/&6&6#,==+6*9);$(	% ()@- 3F )-(K(K  )"% 	""))'%)%?%?$'..$=="?	 "9)% 	
r=   c                     [        U[        5      (       a  [        R                  " U5      $ [        SU< S[	        U5      < S35      e)NzLExpecting dictionary formatted: {"Bucket": bucket_name, "Key": key} but got z	 or type .)
isinstancedictcopy	TypeErrortype)r0   r&   s     r:   r%   <CopySubmissionTask._get_head_object_request_from_copy_source   s<    k4((99[)) [ 13 r=   c                 ,    [        XR                  5      $ N)r	   UPLOAD_PART_COPY_ARGSr0   r'   s     r:   rZ   *CopySubmissionTask._extra_upload_part_args   s     !-G-GHHr=   c                 ,    [        XR                  5      $ rr   )r	   COMPLETE_MULTIPART_ARGSrt   s     r:   r^   1CopySubmissionTask._extra_complete_multipart_args  s     -I-IJJr=   c                 $    X#S-
  :X  a  XBU-  -
  $ U$ )NrL   r!   )r0   rb   
part_indexrd   total_transfer_sizes        r:   r[   %CopySubmissionTask._get_transfer_size  s"    Q& 'y*@AAr=   r!   N)__name__
__module____qualname____firstlineno____doc__r)   rs   rR   rw   r;   r.   r/   r%   rZ   r^   r[   __static_attributes__r!   r=   r:   r   r      sm    5 '%6!.':$4*@':&	'#
'# 	4Kl
2[
z	I
Kr=   r   c                       \ rS rSrSrS rSrg)rH   i  zTask to do a nonmultipart copyc                 L    UR                   " SX#US.UD6  U H	  nU" US9  M     g)a  
:param client: The client to use when calling PutObject
:param copy_source: The CopySource parameter to use
:param bucket: The name of the bucket to copy to
:param key: The name of the key to copy to
:param extra_args: A dictionary of any extra arguments that may be
    used in the upload.
:param callbacks: List of callbacks to call after copy
:param size: The size of the transfer. This value is passed into
    the callbacks

)
CopySourceBucketKeybytes_transferredNr!   )copy_object)	r0   r1   r&   r@   rA   r'   rB   r#   callbacks	            r:   _mainCopyObjectTask._main  s9     	 	J"s	J>H	J!Ht, "r=   r!   Nr}   r~   r   r   r   r   r   r!   r=   r:   rH   rH     s
    (-r=   rH   c                       \ rS rSrSrS rSrg)r]   i$  z)Task to upload a part in a multipart copyc
           	      d    UR                   " SX#UXVS.UD6n
U H	  nU" U	S9  M     U
S   S   nXS.$ )a  
:param client: The client to use when calling PutObject
:param copy_source: The CopySource parameter to use
:param bucket: The name of the bucket to upload to
:param key: The name of the key to upload to
:param upload_id: The id of the upload
:param part_number: The number representing the part of the multipart
    upload
:param extra_args: A dictionary of any extra arguments that may be
    used in the upload.
:param callbacks: List of callbacks to call after copy part
:param size: The size of the transfer. This value is passed into
    the callbacks

:rtype: dict
:returns: A dictionary representing a part::

    {'Etag': etag_value, 'PartNumber': part_number}

    This value can be appended to a list to be used to complete
    the multipart upload.
)r   r   r   UploadId
PartNumberr   CopyPartResultETag)r   r   r!   )upload_part_copy)r0   r1   r&   r@   rA   rO   rN   r'   rB   r#   r9   r   etags                r:   r   CopyPartTask._main&  sY    0 ** F"sF:DF "Ht, "()&188r=   r!   Nr   r!   r=   r:   r]   r]   $  s
    39r=   r]   )rm   rV   s3transfer.tasksr   r   r   r   s3transfer.utilsr   r   r	   r
   r   rH   r]   r!   r=   r:   <module>r      sL      ! + 6 8 * 6 . .q qh-T -, 94  9r=   