ó
    €Ïä  ã                   óˆ   • S r SSKJr  SSKJr  SSKJ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
 rS rS rS rS rS rg)z'Symlink utilities for storage commands.é    )Úabsolute_import)Údivision)Úunicode_literalsN)Útracker_file_util)Úresource_util)Ú
properties)Úfilesc                 ó†   • U(       a  SU [         R                  '   g[         R                  U ;   a  U [         R                  	 gg)z/Updates custom metadata_dict with symlink data.ÚtrueN)r   ÚSYMLINK_METADATA_KEY)Úmetadata_dictÚ
is_symlinks     Ú6lib/googlecloudsdk/command_lib/storage/symlink_util.pyÚ3update_custom_metadata_dict_with_symlink_attributesr      s8   € ö Ø8>€M”-×4Ñ4Ò5Ü×)Ñ)¨]Ó:Ø”m×8Ñ8Ñ9ð ;ó    c                  ó–   • [         R                  R                  R                  R	                  5       n [
        R                  " U 5        U $ )z£Looks up or creates the gcloud storage symlink file directory.

Symlink placeholder files will be kept here.

Returns:
  The path string to the symlink directory.
)r   ÚVALUESÚstorageÚsymlink_placeholder_directoryÚGetr	   ÚMakeDir)Úsymlink_directorys    r   Ú#_create_symlink_directory_if_neededr   '   s<   € ô ×Ñ×Ñ×=Ñ=×AÑAÓCð ô ‡-‚-Ð!Ô"Ø	Ðr   c                 óÔ   • [        5       n[        R                  " [        R                  " U 5      5      n[        R                  " U5        [
        R                  R                  X5      $ )zEReturns a path suitable for storing a placeholder file for a symlink.)r   r   Úget_hashed_file_nameÚget_delimiterless_file_pathÚraise_exceeds_max_length_errorÚosÚpathÚjoin)Úsource_pathr   Úsymlink_filenames      r   Úget_symlink_placeholder_pathr#   7   sO   € ä9Ó;ÐÜ&×;Ò;Ü×3Ò3°KÓ@óÐô ×2Ò2Ð3CÔDÜ	‰‰Ð'Ó	:Ð:r   c                 óæ   • [        U 5      n[        R                  " U5       nUR                  [        R
                  " U 5      R                  S5      5        SSS5        U$ ! , (       d  f       U$ = f)a¡  Creates a placholder file for the given symlink.

The placeholder will be created in the directory specified by the
symlink_placeholder_directory property, and its content will be the path
targeted by the given symlink.

Args:
  source_path: The path to an existing symlink for which a placeholder should
    be created.

Returns:
  The path to the placeholder file that was created to represent the given
  symlink.
zutf-8N)r#   r	   ÚBinaryFileWriterÚwriter   ÚreadlinkÚencode)r!   Úplaceholder_pathÚplaceholder_writers      r   Úget_symlink_placeholder_filer+   A   s]   € ô 2°+Ó>ÐÜ×ÒÐ.Ô/Ð3EØ×ÑœRŸ[š[¨Ó5×<Ñ<¸WÓEÔF÷ 0à	Ð÷ 0Ô/à	Ðús   ¢5A!Á!
A0c                 ó\   • [         R                  " U 5      n[        R                  " X!5        g ©N)r	   ÚReadFileContentsr   Úsymlink)r)   Úsymlink_pathÚsymlink_targets      r   Ú)create_symlink_from_temporary_placeholderr2   V   s   € Ü×)Ò)Ð*:Ó;€.Ü‡*‚*ˆ^Õ*r   c                 ó,   • U (       a  U R                   $ S $ r-   )Úpreserve_symlinks)Úuser_request_argss    r   Ú&get_preserve_symlink_from_user_requestr6   [   s   € Þ0AÐ	×	,Ñ	,ÐKÀtÐKr   )Ú__doc__Ú
__future__r   r   r   r   Ú"googlecloudsdk.command_lib.storager   Ú,googlecloudsdk.command_lib.storage.resourcesr   Úgooglecloudsdk.corer   Úgooglecloudsdk.core.utilr	   r   r   r#   r+   r2   r6   © r   r   Ú<module>r>      sA   ðñ .å &Ý Ý 'ã 	å @Ý FÝ *Ý *ò:òò ;òò*+ó
Lr   