
    "i<                         S SK r S SKrS SKJr  S SKJr  S SKJrJrJ	r	J
r
  S SKJrJrJrJr   " S S\	5      r " S S	\
5      r " S
 S\
5      rg)    N)ClientError)S3CopyFailedError)CompleteMultipartUploadTaskCreateMultipartUploadTaskSubmissionTaskTask)ChunksizeAdjustercalculate_range_parameterget_callbacksget_filtered_dictc            
       r    \ rS rSrSrSSSSSSS	S
SS.	r/ SQr/ SQr/ SQ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ExpectedBucketOwner)	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   r   r   MetadataDirectiveTaggingDirective)r   r   r   r   r   c                    UR                   R                  b  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                  S5      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ETag )metasizeetag	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provide_object_etaggetmultipart_threshold_submit_copy_request_submit_multipart_request)selfclientconfigosutilrequest_executortransfer_futurer)   head_object_requestr,   paramvalueresponses               P/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/s3transfer/copies.py_submitCopySubmissionTask._submitS   sI   ,   %%-##((0 (,,66I>>))  
 #--J !+ 0 0 2@@@  (<<UC !3 !..:: %H   66)
   44X\\&5IJ $$v'A'AA%%/ **/    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)r8   r+   bucketkeyr,   	callbacksr'   T)transfer_coordinatormain_kwargsis_final)r&   r)   r   _transfer_coordinatorsubmitCopyObjectTaskr+   rG   rH   r,   r'   )r7   r8   r9   r:   r;   r<   r)   progress_callbackss           rA   r5   'CopySubmissionTask._submit_copy_request   s     $((22	 +?JG 	""))%)%?%?$#,#8#8'..$=="+"6"6!3+0055 	
rD   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       GH%  nU R)                  UR                  5      n[+        UUS-
  UUR                   R                  5      US'   UR                   R,                  b  UR                   R,                  US'   U R/                  UUS-
  UUR                   R                  5      nUR                  R1                  S5      nUR3                  U R
                  R                  U[5        U R
                  UUR6                  UR                  UR                  UUUUUS.	S	U
0S
95      5        GM(     U R9                  UR                  5      nU R
                  R                  U[;        U R
                  UUR                  UR                  US.U
US.SS95        g )N)r8   rG   rH   r,   )rJ   rK   rF      CopySourceRanger   ChecksumAlgorithm)	r8   r+   rG   rH   part_numberr,   rI   r'   checksum_algorithm	upload_id)rJ   rK   pending_main_kwargs)rX   partsT)rJ   rK   rY   rL   )r&   r)   r,   r-   CREATE_MULTIPART_ARGS_BLACKLISTrM   rN   r   rG   rH   multipart_chunksizer	   adjust_chunksizer'   intmathceilfloatr   range_extra_upload_part_argsr
   r(   _get_transfer_sizer3   appendCopyPartTaskr+   _extra_complete_multipart_argsr   )r7   r8   r9   r:   r;   r<   r)   create_multipart_extra_argsr>   valcreate_multipart_future	part_sizeadjuster	num_partspart_futuresrP   rV   extra_part_argsr'   rW   complete_multipart_extra_argss                        rA   r6   ,CopySubmissionTask._submit_multipart_request   s    $((22	 ')##..446JE@@@58E2 7 #'"<"<"C"C%%)%?%?$'..$=="=	#
 ..	$&--++00
	 IIo**//%	2BBC
	
 *?JG IM2K"::$$O 2Ka$$))	2O-. ##((4#((--   34
 **a$$))	D "+!5!5!9!9:M!N**11$ -1-G-G&,+4+@+@&/&6&6#,==+6*9);$(2D
% ()@-7 3d )-(K(K  )
% 	""))'%)%?%?$'..$=="?	 "9)% 	
rD   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)r7   r+   s     rA   r*   <CopySubmissionTask._get_head_object_request_from_copy_source   sI    k4((99[))&-yk1B0C1F rD   c                 ,    [        XR                  5      $ N)r   UPLOAD_PART_COPY_ARGSr7   r,   s     rA   rc   *CopySubmissionTask._extra_upload_part_args*  s     !-G-GHHrD   c                 ,    [        XR                  5      $ r{   )r   COMPLETE_MULTIPART_ARGSr}   s     rA   rg   1CopySubmissionTask._extra_complete_multipart_args/  s     -I-IJJrD   c                 $    X#S-
  :X  a  XBU-  -
  $ U$ )NrS   r%   )r7   rk   
part_indexrm   total_transfer_sizes        rA   rd   %CopySubmissionTask._get_transfer_size2  s$     Q& 'y*@AArD   r%   N)__name__
__module____qualname____firstlineno____doc__r.   r|   r[   r   rB   r5   r6   r*   rc   rg   rd   __static_attributes__r%   rD   rA   r   r   !   sk    5 '%6!.':$4*@':&4
'#
'#AF
4n
`I
KrD   r   c                       \ rS rSrSrS rSrg)rO   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)	r7   r8   r+   rG   rH   r,   rI   r'   callbacks	            rA   _mainCopyObjectTask._main?  s8     	 	
"s	
>H	
 "Ht, "rD   r%   Nr   r   r   r   r   r   r   r%   rD   rA   rO   rO   <  s
    (-rD   rO   c                   $    \ rS rSrSr SS jrSrg)rf   iU  z)Task to upload a part in a multipart copyNc           	          UR                   " SUUUUUS.UD6nU H	  nU" U	S9  M     US   S   nUUS.nU
(       a'  SU
R                  5        3nUUS   ;   a  US   U   UU'   U$ ! [         aS  nUR                  R                  S0 5      R                  S5      nUS   nUS   nUS:X  a  [	        SU SU S	35      ee S
nAff = f)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
:param checksum_algorithm: The algorithm that was used to create the multipart
    upload

: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. If a checksum is in the response,
    it will also be included.
)r   r   r   UploadId
PartNumberErrorCoder   r   PreconditionFailedzContents of stored object "z" in bucket "z" did not match expected ETag.Nr   CopyPartResultr$   )r$   r   Checksumr%   )upload_part_copyr   r@   r3   r   upper)r7   r8   r+   rG   rH   rX   rV   r,   rI   r'   rW   r@   e
error_codesrc_key
src_bucketr   r(   part_metadatachecksum_members                       rA   r   CopyPartTask._mainX  s'   L	.. &"& H( "Ht, "()&1!%[A ();)A)A)C(DEO(+;"<<19:J1K#2o. -  	488@J!%(G$X.J11'1' ;"", .%%  	s   A& &
C0AB>>Cr%   r{   r   r%   rD   rA   rf   rf   U  s    3  ErD   rf   )rv   r_   botocore.exceptionsr   s3transfer.exceptionsr   s3transfer.tasksr   r   r   r   s3transfer.utilsr	   r
   r   r   r   rO   rf   r%   rD   rA   <module>r      sP      + 3  X Xv-T -2H4 HrD   