+
    –°³j’]  ã                   ó8  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHtHt ^RIHt ^RIHt ]P$                  ! ]4      t]P*                  ! R4      t]P*                  ! R	R
P/                  ]! ]P2                  4      4       R24      tRtRtRtRtRt^
t ]P*                  ! ]PB                  ! ]4       R24      t"R R lt#R R lt$R R lt%R R lt&R R lt'R R lt(R R lt)R  R! lt*R" R# lt+R$ R% lt,R& R' lt-R( R) lt.R* R+ lt/R, R- lt0R. R/ lt1R0 R1 lt2R2R3/R4 R5 llt3R6 R7 lt4R8 R9 lt5R: R; lt6]R< R= l4       t7R> R? lt8R@ RA lt9RB RC lt:RD RE lt;RF RG lt<RHR3/RI RJ llt=RK RL lt>RM RN lt?RO RP lt@RQ RR ltARS RT ltBRU RV ltCR# )Waj  Cache-wide shared blob store, deduplicating Xet files across cached repos.

Store entries at `<cache_dir>/blobs/<2-hex-prefix>/<xet_hash>` are regular files.
Per-repo `blobs/<etag>` entries are relative symlinks to them. A companion
`<xet_hash>.refs` manifest lists those symlinks so cache deletion only needs to inspect
the blobs it touches instead of scanning the entire store.

The manifest is a hint, not trusted metadata: every entry is validated against the
filesystem before use, and any missing or unreadable manifest makes garbage collection
leak the shared blob rather than risk deleting referenced content.
N)Úcontextmanager©ÚPath)Ú	Generator)ÚFileLockÚSoftFileLock)Ú	constants)Úloggingz[0-9a-f]{64}z(?:Ú|z)--.+Úblobsz.huggingface-shared-blobsÚ1z.refsz.lockz\.[0-9a-f]{8}\.tmpc                óF   € V ^8„  d   QhR\         \        ,          R\        /# ©é   Ú	cache_dirÚreturn©Ústrr   )Úformats   "Úd/home/luca/screen-checking/.venv/lib/python3.14/site-packages/huggingface_hub/utils/_shared_blobs.pyÚ__annotate__r   7   s   € ÷ 3ñ 3¤¤d¥
ð 3¬tñ 3ó    c                ó.   € \        V 4      \        ,          # )zBReturn the path of the shared blob store inside a cache directory.)r   ÚSHARED_BLOBS_DIR_NAME)r   s   &r   Úshared_blobs_dirr   7   s   € ä�	‹?Ô2Õ2Ð2r   c                óR   € V ^8„  d   QhR\         \        ,          R\         R\        /# ©r   r   Úxet_hashr   r   )r   s   "r   r   r   <   s*   € ÷ Añ A¤¤d¥
ð A´cð A¼dñ Ar   c                óŽ   € \         P                  V4      f   \        RV R24      h\        V 4      VR,          ,          V,          # )zmReturn the store path for a given Xet file hash.

Raises `ValueError` if `xet_hash` is not a valid Xet hash.
zInvalid Xet file hash: 'ú'.ºNr   N)Ú_XET_HASH_REGEXÚ	fullmatchÚ
ValueErrorr   ©r   r   s   &&r   Úshared_blob_pathr%   <   sC   € ô
 × Ñ  Ó*Ò2ÜÐ3°H°:¸RÐ@ÓAÐAÜ˜IÓ&¨°"­Õ5¸Õ@Ð@r   c                óR   € V ^8„  d   QhR\         \        ,          R\         R\        /# r   r   )r   s   "r   r   r   F   s*   € ÷ \ñ \¬¬t­ð \¼sð \Ätñ \r   c                óF   € \        W4      P                  V \         24      # )z=Return the reference manifest path for a given Xet file hash.)r%   Ú	with_nameÚ_MANIFEST_SUFFIXr$   s   &&r   Úshared_blob_manifest_pathr*   F   s#   € ä˜IÓ0×:Ñ:¸h¸ZÔHXÐGYÐ;ZÓ[Ð[r   c                ó0   € V ^8„  d   QhR\         R\        /# ©r   Úpathr   ©r   Úbool)r   s   "r   r   r   K   s   € ÷ ñ œ4ð ¤Dñ r   c                 ó„   €  \         P                  ! V P                  4       P                  4      #   \         d     R # i ; i©F)ÚstatÚS_ISREGÚlstatÚst_modeÚOSError©r-   s   &r   Ú_is_regular_filer8   K   ó4   € ðÜ�|Š|˜DŸJ™J›L×0Ñ0Ó1Ð1øÜô Úðúó   ‚-0 °?¾?c                ó0   € V ^8„  d   QhR\         R\        /# r,   r.   )r   s   "r   r   r   S   s   € ÷ ñ œð ¤ñ r   c                 ó„   €  \         P                  ! V P                  4       P                  4      #   \         d     R # i ; ir1   )r2   ÚS_ISDIRr4   r5   r6   r7   s   &r   Ú_is_directoryr>   S   r9   r:   c                óJ   € V ^8„  d   QhR\         R\        R,          R\        /# )r   Ú
store_pathÚexpected_sizeNr   )r   Úintr/   )r   s   "r   r   r   [   s%   € ÷ ñ ¤tð ¼CÀ$½Jð Ì4ñ r   c           	     ó¬  € Vf   R#  V P                  4       p\        P                  ! TP                  4      '       g   R# TP
                  T8w  d,   \        P                  RT  RTP
                   RT R24       R# \        P                  ! T \        P                  4      '       g   \        P                  RT  R24       R# R#   \         d     R# i ; i)zPReturn whether `store_path` is a regular, readable payload of the expected size.FzShared blob 'z' has an unexpected size (z instead of z). Not using it.z ' is not readable. Not using it.T)r4   r6   r2   r3   r5   Úst_sizeÚloggerÚwarningÚosÚaccessÚR_OK)r@   rA   Ú
store_stats   && r   Ú_is_usable_store_entryrK   [   sÅ   € àÒáðØ×%Ñ%Ó'ˆ
ô �<Š<˜
×*Ñ*×+Ò+ÙØ×Ñ˜]Ô*Ü�‰Ø˜J˜<Ð'AÀ*×BTÑBTÐAUÐUaÐboÐapð qð ô	
ñ Ü�9Š9�Z¤§¡×)Ò)Ü�‰˜ z lÐ2RÐSÔTÙÙøô ô Úðús   ˆC ÃCÃCc                óF   € V ^8„  d   QhR\         \        ,          R\        /# r,   ©r   r   r/   )r   s   "r   r   r   r   s   € ÷ 	ñ 	œc¤D�jð 	¬Tñ 	r   c                óÔ   € \        V 4      pV\        ,          p\        V4      '       d   \        V4      '       g   R#  VP	                  4       \
         R28H  #   \         d     R# i ; i)z?Return whether `path` is an owned, supported shared blob store.FÚ
)r   ÚSHARED_BLOBS_MARKER_NAMEr>   r8   Ú	read_textÚSHARED_BLOBS_LAYOUT_VERSIONr6   )r-   Ú	store_dirÚmarker_paths   &  r   Úis_shared_blobs_dirrU   r   sc   € ä�T“
€IØÔ6Õ6€KÜ˜×#Ò#Ô+;¸K×+HÒ+HÙðØ×$Ñ$Ó&Ô-HÐ,IÈÐ*LÑLÐLøÜô Úðús   ¾A ÁA'Á&A'c                ó0   € V ^8„  d   QhR\         R\        /# )r   rS   r   r.   )r   s   "r   r   r   ~   s   € ÷ (ñ (¬tð (¼ñ (r   c                ó¸  € \          R2p\        V P                  4       4      pV Fa  p\        P	                  VP
                  4      e   \        V4      '       g    R#  VP                  VP                  4       4      '       g    R# Kc  	  V F  pVP                  RR7       K  	  \        V P                  4       4      '       * #   \        \        3 d      R# i ; i)zŽRemove leftover marker temporaries.

Returns whether the directory is empty afterwards, i.e. safe to mark. Any foreign content returns False.
rO   FT©Ú
missing_ok)rR   ÚlistÚiterdirÚ_MARKER_TMP_REGEXr"   Únamer8   Ú
startswithrQ   r6   ÚUnicodeErrorÚunlinkÚany)rS   Úexpected_contentÚentriesÚentrys   &   r   Ú_cleanup_abandoned_marker_tempsre   ~   sÃ   € ô
 6Ð6°bÐ9ÐÜ�9×$Ñ$Ó&Ó'€GÛˆÜ×&Ñ& u§z¡zÓ2Ò:ÔBRÐSX×BYÒBYÚð	Ø#×.Ñ.¨u¯©Ó/@×AÒAÚñ Bñ	 ó ˆØ�‰ ˆÖ%ñ ä�9×$Ñ$Ó&Ó'Ô'Ð'øô	 œÐ&ô 	Ûð	ús   Á$CÃCÃCc                óF   € V ^8„  d   QhR\         \        ,          R\        /# r   rM   )r   s   "r   r   r   ’   s   € ÷ ñ ¬¬d­
ð ´tñ r   c                óÚ  € \        V 4      pV\        ,          p VP                  RR7       \        V4      '       d   R# \	        V4      '       d   \        V4      '       g   \        P                  RV R24       R# \        W4       VP                  VP                   R\        P                  ! ^4       R24      p VP                  \         R24       VP                  \!        V 4      4       \"        P$                  ! W24       VP'                  RR	7       \        V4      #   TP'                  RR	7       i ; i  \(         d'   p\        P                  R
T RT 24        Rp?R# Rp?ii ; i)zJCreate and mark the shared store, refusing to adopt an unmarked directory.T©Úexist_okz0Refusing to use unmarked shared blob directory 'r   FÚ.ú.tmprO   rX   z,Could not initialize shared blob directory 'ú': N)r   rP   ÚmkdirrU   r>   re   rE   ÚdebugÚ_repair_shared_directory_moder(   r]   ÚsecretsÚ	token_hexÚ
write_textrR   ÚchmodÚ_shared_blob_moderG   Úreplacer`   r6   )r   rS   rT   Ú
tmp_markerÚes   &    r   Ú_ensure_shared_blobs_dirrx   ’   s=  € ä  Ó+€IØÔ6Õ6€KðØ�‰ ˆÔ&Ü˜y×)Ò)ÙÜ˜Y×'Ò'Ô/NÈy×/YÒ/YÜ�L‰LÐKÈIÈ;ÐVXÐYÔZÙÜ% iÔ;à ×*Ñ*¨k×.>Ñ.>Ð-?¸qÄ×ARÒARÐSTÓAUÐ@VÐVZÐ+[Ó\ˆ
ð	/Ø×!Ñ!Ô%@Ð$AÀÐ"DÔEØ×ÑÔ.¨yÓ9Ô:Ü�JŠJ�zÔ/à×Ñ¨ÐÔ.Ü" 9Ó-Ð-øð ×Ñ¨ÐÕ.ûäô Ü�‰ÐCÀIÀ;ÈcÐRSÐQTÐUÔVÝûðús<   š#D9 ¿;D9 Á<A D9 Â=AD" ÄD9 Ä"D6Ä6D9 Ä9E*ÅE%Å%E*c                ó`   € V ^8„  d   QhR\         \        ,          R\         R\        R,          /# )r   r   r   r   Nr   )r   s   "r   r   r   ¬   s)   € ÷ ñ ¤#¬¥*ð ¼ð ÄÀtÅñ r   c                 ó¼  € \        V 4      '       g   R # \        W4      P                  p VP                  RR7       \        T4      '       g   \
        P                  RT R24       R #  \        Y 4       T#   \         d'   p\
        P                  RT RT 24        R p?R # R p?ii ; i  \         d'   p\
        P                  RT RT 24        R p?R # R p?ii ; i)NTrh   z/Could not create shared blob prefix directory 'rl   z2Refusing to use non-directory shared blob prefix 'r   z1Could not set shared blob prefix permissions on ')	rx   r%   Úparentrm   r6   rE   rn   r>   ro   )r   r   Ú
prefix_dirrw   s   &&  r   Ú_ensure_prefix_dirr}   ¬   sÕ   € Ü# I×.Ò.ÙÜ! )Ó6×=Ñ=€JðØ×Ñ $ÐÔ'ô ˜×$Ò$Ü�‰ÐIÈ*ÈÐUWÐXÔYÙðÜ% jÔ<ð Ðøô ô Ü�‰ÐFÀzÀlÐRUÐVWÐUXÐYÔZÝûðûô ô Ü�‰ÐHÈÈÐTWÐXYÐWZÐ[Ô\Ýûðús/   ªA6 Á)B* Á6B'ÂB"Â"B'Â*CÂ5CÃCc                óF   € V ^8„  d   QhR\         \        ,          R\        /# r   ©r   r   rB   )r   s   "r   r   r   À   s"   € ÷ 	mñ 	m¤¤t¥ð 	m´ñ 	mr   c                ól  € \         P                  R8X  d   R#  \        P                  ! \	        V 4      P                  4       P
                  4      pRT\        P                  ,          '       d   ^ M^ ,          T\        P                  ,          '       d	   ^,          # ^ ,          #   \         d     R# i ; i)zLReturn a read-only mode accessible to users who can traverse the cache root.Únté¶  é   )	rG   r]   r2   ÚS_IMODEr   r5   r6   ÚS_IXGRPÚS_IXOTH©r   Ú
cache_modes   & r   rt   rt   À   s†   € ä	‡w�w�$„áðÜ—\’\¤$ y£/×"6Ñ"6Ó"8×"@Ñ"@ÓAˆ
ð ˜Z¬$¯,©,×6Ô6‘E¸AÕ>È:ÔX\×XdÑXd×KdÔKdÀ%ÕlÐlÐjkÕlÐløô ô Úðús   ™7B$ Â$B3Â2B3c                óF   € V ^8„  d   QhR\         \        ,          R\        /# r   r   )r   s   "r   r   r   Ì   s   € ÷ >ñ >¤c¬D¥jð >´Sñ >r   c                óü   €  \         P                  ! \        V 4      P                  4       P                  4      pTR\         P
                  ,          \         P                  ,          ,          #   \         d     R# i ; i)zQMirror cache-root access and inheritance bits on newly created store directories.iÀ  iÿ  )r2   r„   r   r5   r6   ÚS_ISGIDÚS_ISVTXr‡   s   & r   Ú_shared_directory_moder�   Ì   s[   € ðÜ—\’\¤$ y£/×"6Ñ"6Ó"8×"@Ñ"@ÓAˆ
ð ˜¤§¡Õ-´·±Õ<Õ=Ð=øô ô Úðús   ‚7A, Á,A;Á:A;c                óJ   € V ^8„  d   QhR\         R\        \         ,          RR/# )r   r-   r   r   N©r   r   )r   s   "r   r   r   Õ   s%   € ÷ "ñ "¬ð "¼¼t½ð "Èñ "r   c                 ó¨   € \        V4      p\        P                  ! V P                  4       P                  4      V8w  d   V P                  V4       R # R # ©N)r�   r2   r„   r4   r5   rs   )r-   r   Úexpected_modes   && r   ro   ro   Õ   s:   € Ü*¨9Ó5€MÜ‡|‚|�D—J‘J“L×(Ñ(Ó)¨]Ô:Ø�
‰
�=Ö!ñ ;r   c                óV   € V ^8„  d   QhR\         R\         R\        \         ,          RR/# )r   Ú	blob_pathr|   r   r   Nr�   )r   s   "r   r   r   Û   s0   € ÷ ñ ´ð Ä$ð ÔSVÔY]ÕS]ð Ðbfñ r   c                óê  € \        V4      p\        P                  ! W4       \        P                  R8X  g   \	        \        R4      '       g   R# VP                  4       P                  pV P                  4       P                  V8X  d   R#  \        P                  ! V RV4       R#   \         dC    T\
        P                  ,          '       d"   T\
        P                  ,          '       g   h  R#  R# i ; i)zKMake a payload immutable and readable according to the shared cache policy.r�   ÚchownNéÿÿÿÿ)rt   rG   rs   r]   Úhasattrr2   Úst_gidr–   r6   ÚS_IRGRPÚS_IROTH)r”   r|   r   Ú	blob_modeÚ
target_gids   &&&  r   Ú _prepare_shared_blob_permissionsrž   Û   s©   € ä! )Ó,€IÜ‡H‚HˆYÔ"Ü	‡w�w�$„œg¤b¨'×2Ò2ÙØ—‘Ó"×)Ñ)€JØ‡~�~Ó×Ñ *Ô,ÙðÜ
�Š�˜B 
Ö+øÜô à”t—|‘|×#Ô#¨I¼¿¹×,DÔ,DØò -EÒ#ðús   ÂB% Â%'C2ÃC2Ã*C2Ã1C2c                óF   € V ^8„  d   QhR\         \        ,          R\        /# r,   r   )r   s   "r   r   r   ì   s   € ÷ +ñ +œs¤T�zð +¬dñ +r   c                ó  € \         P                  ! V 4      pVR,          P                  4       R8X  d   RVR,           2pM VP                  R4      '       d
   VR,          p\	        \         P
                  P                  V4      4      # )zCReturn an absolute path without the Windows extended-length prefix.:Né   Nz\\?\unc\z\\:r¡   NNz\\?\:é   NN)rG   ÚfspathÚlowerr^   r   r-   Úabspath)r-   Úpath_strs   & r   Ú_path_for_comparisonr§   ì   sf   € ä�yŠy˜‹€HØ�…|×ÑÓ˜~Ô-Ø˜( 2�,˜Ð(‰Ø	×	Ñ	˜Y×	'Ò	'Ø˜B•<ˆÜ”—‘—‘ Ó)Ó*Ð*r   c                óv   € V ^8„  d   QhR\         \        ,          R\         \        ,          R\         R,          /# ©r   r”   r   r   Nr   )r   s   "r   r   r   ö   s2   € ÷ Rñ R¤3¬¥:ð R¼#Ä½*ð RÌÈtÍñ Rr   c                 ó¤  € \        V 4      p \        V4      p V P                  V4      p\        TP                  4      ^8w  gZ   \
        P                  TP                  ^ ,          4      e2   TP                  ^,          R8w  g   TP                  ^,          '       g   R # TP                  4       pRT9   g   RT9   d   R # T#   \         d     R # i ; i)Nr   rO   Ú)r§   Úrelative_tor#   ÚlenÚpartsÚ_REPO_DIR_REGEXr"   Úas_posix)r”   r   Úrelative_pathÚrelative_strs   &&  r   Ú_relative_blob_pathr³   ö   s¾   € Ü$ YÓ/€IÜ$ YÓ/€IðØ!×-Ñ-¨iÓ8ˆô 	ˆM×ÑÓ  AÔ%Ü×$Ñ$ ]×%8Ñ%8¸Õ%;Ó<ÒDØ×Ñ˜qÕ! WÔ,Ø×"Ñ" 1×%Ô%áØ ×)Ñ)Ó+€LØ˜<Ô'¨4°<Ô+?ˆ4ÐQÀ\ÐQøô ô Úðús   ˜C  Ã CÃCÚraise_on_io_errorFc          	      ó‚   € V ^8„  d   QhR\         \        ,          R\         \        ,          R\        R\        R,          /# )r   r”   r   r´   r   NrM   )r   s   "r   r   r     s8   € ÷  9ñ  9Ü”T�zð 9Ü&)¬D¥jð 9ÜHLð 9ä	ˆD…[ñ 9r   c               ó0  € \        V 4      p \        W4      f   R#  \        P                  ! V P	                  4       P
                  4      '       g   R# \        \        P                  ! V 4      4      p\        T 4      pTP                  4       '       d   TMTP                  T,          p\        T4      p\        \        T4      4      p TP                  T4      p\!        TP"                  4      ^8w  gY   \$        P'                  TP"                  ^,          4      e1   TP"                  ^ ,          TP"                  ^,          R,          8w  d   R# \        T4      T,          #   \         d     R# \         d    T'       d   h  R# i ; i  \         d     R# i ; i)zMReturn the canonical store target if `blob_path` is a managed shared symlink.Nr    )r   r³   r2   ÚS_ISLNKr4   r5   rG   ÚreadlinkÚFileNotFoundErrorr6   r§   Úis_absoluter{   r   r¬   r#   r­   r®   r!   r"   )r”   r   r´   Úlink_targetÚcomparable_blob_pathÚtargetrS   Úrelative_targets   &&$     r   Ú_shared_blob_targetr¿     sO  € ô �Y“€IÜ˜9Ó0Ò8Ùð	Ü�|Š|˜IŸO™OÓ-×5Ñ5×6Ò6ÙÜœ2Ÿ;š; yÓ1Ó2ˆô 0°	Ó:ÐØ'×3Ñ3×5Ò5‰[Ð;O×;VÑ;VÐYdÕ;d€FÜ! &Ó)€FÜ$Ô%5°iÓ%@ÓA€IðØ ×,Ñ,¨YÓ7ˆô 	ˆO×!Ñ!Ó" aÔ'Ü×$Ñ$ _×%:Ñ%:¸1Õ%=Ó>ÒFØ× Ñ  Õ# ×'<Ñ'<¸QÕ'?ÀÕ'CÔCáÜ˜IÓ&¨Õ8Ð8øô+ ô ÚÜô ßØÚðûô ô Úðús;   œ3E ÁE ÃF ÅFÅ,FÅ5FÅ>FÆFÆFÆFc                óv   € V ^8„  d   QhR\         \        ,          R\         \        ,          R\        R,          /# r©   r   )r   s   "r   r   r   +  s2   € ÷ Oñ O¤#¬¥*ð O¼¼t½ð OÌÈtÍñ Or   c                óJ   € \        W4      pVe   \        V4      '       d   V# R# )z“Return the canonical store target if `blob_path` is a valid shared symlink.

Callers check `is_shared_blobs_dir` once before resolving many blobs.
N)r¿   r8   )r”   r   r½   s   && r   Úshared_blob_targetrÂ   +  s)   € ô
 ! Ó6€FØÒ'Ô,<¸V×,DÒ,Dˆ6ÐNÈ$ÐNr   c                ó0   € V ^8„  d   QhR\         R\         /# ©r   r@   r   r   )r   s   "r   r   r   4  s   € ÷ Hñ H¬dð H´tñ Hr   c                 óH   € V P                  V P                   \         24      # r‘   )r(   r]   r)   ©r@   s   &r   Ú_manifest_path_for_store_pathrÇ   4  s#   € Ø×Ñ :§?¡?Ð"3Ô4DÐ3EÐ FÓGÐGr   c                ó0   € V ^8„  d   QhR\         R\         /# rÄ   r   )r   s   "r   r   r   8  s   € ÷ Dñ D¬$ð D´4ñ Dr   c                 óH   € V P                  V P                   \         24      # r‘   )r(   r]   Ú_LOCK_SUFFIXrÆ   s   &r   Ú_lock_path_for_store_pathrË   8  s!   € Ø×Ñ :§?¡?Ð"3´L°>Ð BÓCÐCr   c                ó>   € V ^8„  d   QhR\         R\        R,          /# )r   r@   r   )NNN)r   r   )r   s   "r   r   r   =  s    € ÷  ñ  ¤$ð  ¬9Ð5EÕ+Fñ  r   c              #  ó²  "  € \        V 4      p\        P                  \        P                  ,          p\	        \        R4      '       d   V\        P
                  ,          p\        P                  ! WR4      p \        P                  ! \        P                  ! V4      P                  4      '       g   \        RV R24      h\	        \        R4      '       d    \        P                  ! VR4       \        P                  ! V4       \        VRR7      p VP                  4         R	x €  VP'                  4        R	#   \         d     LYi ; i  \        P                  ! T4       i ; i  \          d*    \#        T R2RR7      pTP                  \$        R7        Lwi ; i  \         d     R	# i ; i   TP'                  4        i   \         d     i i ; i; i5i)
zBLock publication, reference creation, and GC for one content hash.Ú
O_NOFOLLOWr‚   z)Shared blob lock is not a regular file: 'r   Úfchmod)Úmodez.soft)ÚtimeoutN)rË   rG   ÚO_WRONLYÚO_CREATr˜   rÎ   Úopenr2   r3   Úfstatr5   r6   rÏ   Úcloser   ÚacquireÚNotImplementedErrorr   Ú_SOFT_LOCK_TIMEOUTÚrelease)r@   Ú	lock_pathÚflagsÚfdÚlocks   &    r   Ú_shared_blob_lockrß   <  sk  é € ô *¨*Ó5€Iô �K‰Kœ"Ÿ*™*Õ$€EÜŒr�<× Ò Ø”—‘ÕˆÜ	�Š� 5Ó	)€Bð	Ü�|Š|œBŸHšH R›L×0Ñ0×1Ò1ÜÐEÀiÀ[ÐPRÐSÓTÐTÜ”2�x× Ò ðÜ—	’	˜"˜eÔ$ô 	�Š�ŒÜ�I EÔ*€Dð1Ø�‰Œð
Ûð	Ø�L‰LŽNøô ô Ùðûô 	�Š��ûô ô 1ä˜y˜k¨Ð/°eÔ<ˆØ�‰Ô/ˆÖ0ð1ûô ô 	Úð	ûð	Ø�L‰L�NøÜô 	Ùð	ÿsµ   ‚A5GÁ8AE ÃD; Ã/#GÄE' Ä$F0 Ä)F Ä9GÄ;E	ÅE ÅE	Å	E ÅE$Å$GÅ'1FÆGÆFÆGÆF-Æ)GÆ,F-Æ-GÆ0GÆ2GÇGÇGÇGÇGÇGÇGc                ó4   € V ^8„  d   QhR\         R\        RR/# )r   Úmanifest_pathÚrelative_blob_pathr   Nr�   )r   s   "r   r   r   `  s"   € ÷ ñ ¬dð Ìð ÐPTñ r   c                ó.  € \         P                  \         P                  ,          \         P                  ,          p\	        \         R4      '       d   V\         P
                  ,          p\         P                  ! WR4      p \        P                  ! \         P                  ! V4      P                  4      '       g   \        RV  R24      h\	        \         R4      '       d    \         P                  ! VR4       V R2P                  4       p\         P                  ! W44      \        V4      8w  d   \        RV  R24      h\         P                   ! V4       \         P"                  ! V4       R#   \         d     L�i ; i  \         P"                  ! T4       i ; i)	zBAppend and flush one reference before its symlink is made visible.rÎ   r‚   z-Shared blob manifest is not a regular file: 'r   rÏ   rO   z*Could not append a complete reference to 'N)rG   rÒ   ÚO_APPENDrÓ   r˜   rÎ   rÔ   r2   r3   rÕ   r5   r6   rÏ   ÚencodeÚwriter­   ÚfsyncrÖ   )rá   râ   rÜ   rÝ   Úlines   &&   r   Ú_append_manifest_referenceré   `  s  € ä�K‰Kœ"Ÿ+™+Õ%¬¯
©
Õ2€EÜŒr�<× Ò Ø”—‘ÕˆÜ	�Š� uÓ	-€BðÜ�|Š|œBŸHšH R›L×0Ñ0×1Ò1ÜÐIÈ-ÈÐXZÐ[Ó\Ð\Ü”2�x× Ò ðÜ—	’	˜"˜eÔ$ð %Ð% RÐ(×/Ñ/Ó1ˆÜ�8Š8�BÓ¤ T£Ô*ÜÐFÀ}ÀoÐUWÐXÓYÐYÜ
�Š�Œä
�Š�Žøô ô Ùðûô 	�Š��ús2   Â AE< Ã E+ Ã7AE< Å+E9Å6E< Å8E9Å9E< Å<Fc                ó<   € V ^8„  d   QhR\         R\         R\         /# )r   r”   r@   r   r   )r   s   "r   r   r   v  s!   € ÷ ñ ¤tð ¼ð Ä$ñ r   c                 ó  € V P                  R V P                   R \        P                  ! ^4       R24      p\        P
                  P                  \        V4      \        V 4      P                  R7      p\        P                  ! W24       V# )rj   z.shared)Ústart)
r(   r]   rp   rq   rG   r-   Úrelpathr§   r{   Úsymlink)r”   r@   Útmp_linkr¾   s   &&  r   Ú_make_temporary_symlinkrð   v  sl   € Ø×"Ñ" Q y§~¡~Ð&6°a¼×8IÒ8IÈ!Ó8LÐ7MÈWÐ#UÓV€HÜ—g‘g—o‘oÔ&:¸:Ó&FÔNbÐclÓNm×NtÑNt�oÓu€OÜ‡J‚JˆÔ)Ø€Or   c                ó$   € V ^8„  d   QhR\         /# )r   r   )r/   )r   s   "r   r   r   }  s   € ÷ Zñ Zœdñ Zr   c                 óf   € \         P                  '       * ;'       d    \         P                  '       * # )z1Return whether the shared blob store may be used.)r   ÚHF_HUB_DISABLE_SHARED_BLOBSÚHF_HUB_DISABLE_XET© r   r   Úshared_blobs_enabledrö   }  s"   € ä×4Ñ4Ô4×YÐY¼Y×=YÑ=YÔ9YÐYr   c          
      óx   € V ^8„  d   QhR\         R\         R\         \        ,          R\        R,          R\        /# )r   r”   r   r   rA   Nr   ©r   r   rB   r/   )r   s   "r   r   r   ‚  s=   € ÷  ñ  Üð Ü!$ð Ü14´tµð ÜLOÐRVÍJð ä	ñ r   c                ó  € \         P                  V4      e   \        \        V4      4      '       g   R# \	        W!4      p\        W4      pVf   R# Rp \        V4      ;_uu_ 4        \        WC4      '       g$    RRR4       Ve   VP                  RR7       R# R# \        \        V 4      V4      p\        \        V4      V4       \        P                  ! W`4       RRR4       Te   TP                  RR7       \         P#                  RT  R24       R#   + '       g   i     LA; i  \         d?   p\         P#                  RT  RT 24        Rp?Te   TP                  RR7       R# R# Rp?ii ; i  Te   TP                  RR7       i i ; i)	zâMaterialize `blobs/<etag>` as a symlink to an existing store entry, if any.

The reference manifest is flushed before the symlink becomes visible. Failures are
best-effort misses and leave the regular download path untouched.
NFTrX   zCould not symlink 'z' from shared blob store: úBlob 'z5' reused from shared blob store (no download needed).)r!   r"   rU   r   r%   r³   rß   rK   r`   rð   r   ré   rÇ   rG   ru   r6   rE   rn   )r”   r   r   rA   r@   râ   rï   rw   s   $$$$    r   Útry_link_from_shared_storerû   ‚  s\  € ô × Ñ  Ó*Ò2Ô:MÔN^Ð_hÓNi×:jÒ:jÙÜ! )Ó6€JÜ,¨YÓBÐØÒ!Ùà €Hð-Ü˜z×*Õ*Ü)¨*×DÒDØ÷ +ð ÒØ�O‰O tˆOÖ,ñ  ô /¬t°I«À
ÓKˆHÜ&Ô'DÀZÓ'PÐRdÔeÜ�JŠJ�xÔ+÷ +ð ÒØ�O‰O tˆOÔ,ä
‡L�L�6˜)˜Ð$YÐZÔ[Ù÷ +×*ûô ô Ü�‰Ð*¨9¨+Ð5OÐPQÈsÐSÔTÛàÒØ�O‰O tˆOÖ,ñ  ûð	ûð ÒØ�O‰O tˆOÕ,ð  ús[   ÁD' Á&DÁ9D' ÂA DÃD' ÄD$	ÄD' Ä#E3 Ä$D' Ä'E0Ä2E+ÅE3 Å+E0Å0E3 Å3Fc                ól   € V ^8„  d   QhR\         R\         \        ,          R\        R,          R\        /# )r   r   r   rA   Nr   rø   )r   s   "r   r   r   ¥  s8   € ÷ Xñ X¤ð X´´tµð XÌCÐRVÍJð XÔ[_ñ Xr   c                ó²   € \        4       '       d2   \        P                  V 4      e   \        \	        V4      4      '       g   R# \        \        W4      V4      # )zGReturn whether a usable store entry exists, without touching the cache.F)rö   r!   r"   rU   r   rK   r%   )r   r   rA   s   $$$r   Úhas_shared_blobrþ   ¥  sE   € ô !×"Ò"Ü×$Ñ$ XÓ.Ò6Ü"Ô#3°IÓ#>×?Ò?áÜ!Ô"2°9Ó"GÈÓWÐWr   Úreplace_existingc                ó„   € V ^8„  d   QhR\         R\         R\         \        ,          R\        R,          R\        R\        /# )r   r”   r   r   rA   Nrÿ   r   rø   )r   s   "r   r   r   °  sN   € ÷ 4ñ 4äð4ô ð4ô ”T�zð	4ô
 ˜•:ð4ô ð4ô 
ñ4r   c                óÐ  € Ve   \         P                  V4      f   R# \        W!4      p\        W4      pVe   Vf   R# \	        V 4      p\        W!4      p\        V4      p	Rp
Rp \        V4      ;_uu_ 4        \        Wx4      p
V'       * ;'       d    \        Wƒ4      p\        W–4       V'       g%   \        WuV4       \        P                  ! Wx4       Rp \        P                  ! W§4        RRR4       T
e   T
P'                  RR7       \"        P%                  R	T  R
24       R#   \         d#    T'       d   \        P                   ! Y‡4       Rph i ; i  + '       g   i     Lq; i  \         dW   p\"        P%                  RT  RT 24       T'       d   \        RT  R24      Th Rp?T
e   T
P'                  RR7       R# R# Rp?ii ; i  T
e   T
P'                  RR7       i i ; i)zãMove a fresh Xet download into the store and replace its repo blob with a symlink.

Best-effort: on failure the repo blob remains (or is restored as) a regular local
file. Returns whether the repo blob was successfully shared.
NFTzCould not publish 'z' to shared blob store: zCould not restore repo blob 'z' after shared-store failurerX   rú   z!' published to shared blob store.)r!   r"   r}   r³   r   r%   rÇ   rß   rð   rK   ré   rž   rG   ru   r6   ÚshutilÚcopyfilerE   rn   r`   )r”   r   r   rA   rÿ   r|   râ   Úblob_path_objr@   rá   rï   Ú
blob_movedÚstore_is_usablerw   s   $$$$$         r   Úpublish_blob_to_shared_storer  °  s´  € ð Ò¤× 9Ñ 9¸(Ó CÒ KÙÜ# IÓ8€JÜ,¨YÓBÐØÒÐ/Ò7Ùä˜“O€MÜ! )Ó6€JÜ1°*Ó=€MØ €HØ€Jð-Ü˜z×*Õ*Ü.¨}ÓIˆHØ"2Ô2×hÐhÔ7MÈjÓ7hˆOÜ& }ÔIß"Ü0°ÈIÔVÜ—
’
˜=Ô5Ø!�
ðÜ—
’
˜8Õ3÷ +ð* ÒØ�O‰O tˆOÔ,ä
‡L�L�6˜)˜Ð$EÐFÔGÙøô ô ßÜ—O’O JÔ>Ø!&�JØð	ú÷ +×*ûô ô Ü�‰Ð*¨9¨+Ð5MÈaÈSÐQÔRßÜÐ9¸)¸ÐD`ÐaÓbÐhiÐiÛàÒØ�O‰O tˆOÖ,ñ  ûðûð ÒØ�O‰O tˆOÕ,ð  úsm   Á$E( Á7AEÃD%Ã,E( Ä%EÄ8EÅEÅE%	Å E( Å$G Å%E( Å(G	Å33GÆ&G Æ-G ÇG	Ç	G ÇG%c                óv   € V ^8„  d   QhR\         R\        \         ,          R\        \         ,          R,          /# )r   r@   r   r   N)r   r   Úset)r   s   "r   r   r   ç  s2   € ÷ ñ ´ð ÄÄtÅð ÔPSÔTXÕPYÐ\`ÕP`ñ r   c                 ó0  € \        V 4      p\        V4      '       g   R #  VP                  4       P                  4       p\        4       p\        \        P                  P                  T4      4      pT Fu  p\        T4      pTP                  4       '       g   RTP                  9   d   K7  Y,          p\        Yq4      f   KN   \        YqRR7      pY€8X  g   Kd  TP                  T4       Kw  	  T#   \        \
        3 d     R # i ; i  \         d      R # i ; i)Nz..T)r´   )rÇ   r8   rQ   Ú
splitlinesr6   r_   r	  r   rG   r-   r¥   rº   r®   r³   r¿   Úadd)	r@   r   rá   ÚlinesÚ
referencesrè   r±   Ú	candidater½   s	   &&       r   Ú_read_valid_manifest_referencesr  ç  sø   € Ü1°*Ó=€MÜ˜M×*Ò*ÙðØ×'Ñ'Ó)×4Ñ4Ó6ˆô  ›E€JÜ”R—W‘W—_‘_ YÓ/Ó0€IÛˆÜ˜T›
ˆØ×$Ñ$×&Ò&¨$°-×2EÑ2EÔ*EÙØÕ-ˆ	Ü˜yÓ4Ò<Ùð	Ü(¨ÐQUÔVˆFð ÖØ�N‰N˜9Ö%ñ ð Ðøô% ”\Ð"ô Úðûô ô 	Ûð	ús#    C- ÃDÃ-DÄDÄDÄDc                ót   € V ^8„  d   QhR\         R\        \         ,          R\        \         ,          R\        /# )r   r@   Úblob_paths_to_deleter   r   )r   r	  r   rB   )r   s   "r   r   r     s4   € ÷ 
ñ 
Üð
Ü/2´4­yð
ÜEHÌ4ÅZð
äñ
r   c               óâ   € \        W4      pVe    V'       d   VP                  V4      '       g   ^ #  \        V 4      '       d   V P                  4       P                  # ^ #   \
         d     ^ # i ; i)zHPredict bytes freed if all known references are part of a deletion plan.)r  Úissubsetr8   r4   rD   r6   )r@   r  r   r  s   &$$ r   Úexpected_shared_blob_freed_sizer    se   € ô 1°ÓG€JØÒ§°:×3FÑ3FÐG[×3\Ò3\ÙðÜ-=¸j×-IÒ-Iˆz×ÑÓ!×)Ñ)ÐPÈqÐPøÜô Úðús   ²*A ÁA ÁA.Á-A.c                ó\   € V ^8„  d   QhR\         \        ,          R\        \        ,          /# r   )r   r   r	  )r   s   "r   r   r     s"   € ÷ ñ ¤s¬T¥zð ´c¼$µiñ r   c                ó�  € \        V 4      p\        V4      '       g   \        4       # \        4       p \        VP	                  4       4      pT FÐ  p\        P                  ! RTP                  4      e   \        T4      '       g   K9   \        TP	                  4       4      pT Fw  p\        P                  TP                  4      f   K&  TP                  P                  TP                  4      '       g   KS  \        T4      '       g   Kf  TP                  T4       Ky  	  KÒ  	  T#   \
         d    Tu # i ; i  \
         d     K÷  i ; i)zBReturn all valid canonical payload paths in a marked shared store.z[0-9a-f]{2})r   rU   r	  rZ   r[   r6   Úrer"   r]   r>   r!   r^   r8   r  )r   rS   ÚpathsÚprefix_dirsr|   rc   rd   s   &      r   Úshared_store_blob_pathsr    s  € ä  Ó+€IÜ˜y×)Ò)Ü‹uˆÜ“u€EðÜ˜9×,Ñ,Ó.Ó/ˆó "ˆ
Ü�<Š<˜¨
¯©Ó8Ò@ÌÐV`×HaÒHaÙð	Ü˜:×-Ñ-Ó/Ó0ˆGó ˆEä×)Ñ)¨%¯*©*Ó5ÔAØ—J‘J×)Ñ)¨*¯/©/×:Ô:Ü$ U×+Ô+à—	‘	˜%Ö ó ñ "ð €Løô! ô ØŠðûô ô 	Úð	ús#   ²D# ÂD6Ä#D3Ä2D3Ä6EÅEc                óh   € V ^8„  d   QhR\         \        ,          R\        \        \        3,          /# r   )r   r   ÚdictrB   )r   s   "r   r   r   *  s&   € ÷ ñ ¬¬t­ð ¼¼TÄ3¸Y½ñ r   c                óÂ   € / p\        V 4       F;  p\        W 4      pVf   K  V'       d   K   VP                  4       P                  W&   K=  	  V#   \         d     KO  i ; i)z³Return store payloads without any valid manifest reference, with their sizes.

Payloads with a missing or unreadable manifest are not listed, consistent with `sweep_shared_blob`.
)r  r  r4   rD   r6   )r   Úunreferencedr@   r  s   &   r   Úunreferenced_shared_blobsr   *  sd   € ð
 %'€LÜ-¨iÖ8ˆ
Ü4°ZÓKˆ
ØÔ!¯*©*ðØ+5×+;Ñ+;Ó+=×+EÑ+E�Ó(ñ	 9ð Ðøô ô Úðús   ­AÁAÁAc                ól   € V ^8„  d   QhR\         R\        \         ,          R\        \         ,          RR/# )r   rá   r  r   r   N)r   r	  r   )r   s   "r   r   r   :  s2   € ÷ )ñ )¤Tð )´s¼4µyð )ÌSÔSWÍZð )Ð\`ñ )r   c                 ó€  a€ V P                  V P                   R \        P                  ! ^4       R24      p\	        \
        P                  P                  S4      4      o RP                  V3R l\        V4       4       4      pVP                  V4       VP                  R4       VP                  R4      ;_uu_ 4       p\
        P                  ! VP                  4       4       RRR4       \
        P                  ! W04       VP!                  RR7       R#   + '       g   i     L:; i  TP!                  RR7       i ; i)	rj   rk   Ú c              3   óf   <"  € T F&  qP                  S4      P                  4        R 2x € K(  	  R# 5i)rO   N)r¬   r°   )Ú.0r-   r   s   & €r   Ú	<genexpr>Ú$_rewrite_manifest.<locals>.<genexpr>>  s-   øé € ÐgÑTfÈD×-Ñ-¨iÓ8×AÑAÓCÐDÀBÕGÓTfùs   ƒ.1r‚   ÚrbNTrX   )r(   r]   rp   rq   r   rG   r-   r¥   ÚjoinÚsortedrr   rs   rÔ   rç   Úfilenoru   r`   )rá   r  r   Útmp_pathÚcontentÚfiles   &&f   r   Ú_rewrite_manifestr/  :  sâ   ø€ Ø×&Ñ&¨-×*<Ñ*<Ð)=¸Q¼w×?PÒ?PÐQRÓ?SÐ>TÐTXÐ'YÓZ€HÜ”R—W‘W—_‘_ YÓ/Ó0€Ið)Ø—'‘'ÔgÔTZÐ[eÔTfÓgÓgˆØ×Ñ˜GÔ$Ø�‰�uÔØ�]‰]˜4× Ô  DÜ�HŠH�T—[‘[“]Ô#÷ !ä
�
Š
�8Ô+à�‰ 4ˆÖ(÷	 !× ûð 	�‰ 4ˆÕ(ús%   Á AD) Â?%DÃ$D) ÄD&	Ä!D) Ä)D=c                óR   € V ^8„  d   QhR\         R\        \         ,          R\        /# )r   r@   r   r   )r   r   rB   )r   s   "r   r   r   H  s%   € ÷ &ñ &¤$ð &´c¼Dµjð &ÄSñ &r   c               óJ  € \        \        P                  P                  V 4      4      p \        \        P                  P                  V4      4      p\        \        P                  P                  \	        V4      4      4      p V P                  V4      p\        T4      '       dh   \        TP                  4      ^8w  gN   \        P                  T P                  4      e-   T P                  P                  T P                  R,          8w  d   ^ #  \        T 4      ;_uu_ 4        \        Y4      pTf    RRR4       ^ # \!        T 4      pT'       d   \#        YTT4        RRR4       ^ # \%        T 4      '       g    RRR4       ^ # T P'                  4       P(                  pT P+                  4        TP+                  RR7       TuuRRR4       #   \         d     ^ # i ; i  + '       g   i     R# ; i  \,         d'   p\.        P1                  RT  RT 24        Rp?^ # Rp?ii ; i)zÁCollect one shared blob if its manifest has no remaining valid references.

Missing, invalid, or unreadable metadata is never grounds for deletion. Returns the
number of payload bytes removed.
Nr    TrX   zCould not collect shared blob 'rl   )r   rG   r-   r¥   r   r¬   r#   rU   r­   r®   r!   r"   r]   r{   rß   r  rÇ   r/  r8   r4   rD   r`   r6   rE   rn   )r@   r   Úexpected_store_dirÚrelative_store_pathr  rá   Úsizerw   s   &$      r   Úsweep_shared_blobr5  H  s±  € ô ”b—g‘g—o‘o jÓ1Ó2€JÜ”R—W‘W—_‘_ YÓ/Ó0€IÜœbŸg™gŸo™oÔ.>¸yÓ.IÓJÓKÐðØ(×4Ñ4Ð5GÓHÐô  Ð 2×3Ò3ÜÐ"×(Ñ(Ó)¨QÔ.Ü×$Ñ$ Z§_¡_Ó5Ò=Ø×Ñ×!Ñ! Z§_¡_°RÕ%8Ô8áðÜ˜z×*Õ*Ü8¸ÓOˆJØÒ!Ø÷ +Ñ*ô :¸*ÓEˆMßÜ! -¸YÔGØ÷ +Ñ*ô $ J×/Ò/Ø÷ +Ñ*ð ×#Ñ#Ó%×-Ñ-ˆDØ×ÑÔØ× Ñ ¨DÐ Ô1Ø÷ +Ò*øô ô Úðú÷ +×*Ð*ûô ô Ü�‰Ð6°z°lÀ#ÀaÀSÐIÔJÝûðúsl   ÂG ÄG1 Ä"GÄ3G1 Ä= GÅG1 Å'GÅ9G1 Æ=GÇ 
G1 ÇGÇGÇG.	Ç(G1 Ç.G1 Ç1H"Ç<HÈH")DÚ__doc__rG   r  rp   r  r2   Ú
contextlibr   Úpathlibr   Útypingr   Úfilelockr   r   r#  r   r	   Ú
get_loggerÚ__name__rE   Úcompiler!   r)  r*  ÚREPO_TYPES_MAPPINGr¯   r   rP   rR   r)   rÊ   rÙ   Úescaper\   r   r%   r*   r8   r>   rK   rU   re   rx   r}   rt   r�   ro   rž   r§   r³   r¿   rÂ   rÇ   rË   rß   ré   rð   rö   rû   rþ   r  r  r  r  r   r/  r5  rõ   r   r   Ú<module>r@     s’  ðñ
ó 
Û 	Û Û Û Ý %Ý Ý ç +å Ý ð 
×	Ò	˜HÓ	%€à—*’*˜_Ó-€Ø—*’*  C§H¡H©V°I×4PÑ4PÓ-QÓ$RÐ#SÐSXÐYÓZ€àÐ Ø6Ð Ø!Ð ØÐ Ø€ØÐ Ø—J’J 2§9¢9Ð-EÓ#FÐ"GÐG[Ð\Ó]Ð õ3õ
Aõ\õ
õõõ.	õ(õ(õ4õ(	mõ>õ"õõ"+õRð$ 9ØOT÷ 9õFOõHõDð ô ó ð õFõ,õZõ
 õFXð4ð #÷4õnõ6
õõ6õ )÷&r   