+
    &j6!                       a  0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	  ^ RI
t]'       d'   ^ RIHt ^ RIHtHtHt ^RIHt ]]]3,          tR]R	&    ! R
 R4      tR#   ] d    ]'       g   ^ RIt LOi ; i)    )annotationsN)TYPE_CHECKING)atomic_write)Iterator)AnyLiteral	TypeAlias)CachingFileSystemr	   Detailc                      ] tR t^tRtR R ltR R ltR R ltRR R	 l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tR# )CacheMetadataaD  Cache metadata.

All reading and writing of cache metadata is performed by this class,
accessing the cached files and blocks is not.

Metadata is stored in a single file per storage directory in JSON format.
For backward compatibility, also reads metadata stored in pickle format
which is converted to JSON when next saved.
c                   V ^8  d   QhRR/# )   storagez	list[str] )formats   "}/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/fsspec/implementations/cache_metadata.py__annotate__CacheMetadata.__annotate__$   s     ( (	 (    c                V    V'       g   \        R4      hWn        / .V n        RV n        R# )z

Parameters
----------
storage: list[str]
    Directories containing cached files, must be at least one. Metadata
    is stored in the last of these directories by convention.
z3CacheMetadata expects at least one storage locationFN)
ValueError_storagecached_files_force_save_pickle)selfr   s   &&r   __init__CacheMetadata.__init__$   s,     RSS+-$ #(r   c                    V ^8  d   QhRRRR/# )r   fnstrreturnr   r   )r   s   "r   r   r   7   s        r   c                    \        VR4      ;_uu_ 4       p\        P                  ! V4      pRRR4       XP                  4        F?  p\        TP                  R4      \        4      '       g   K*  \        TR,          4      TR&   KA  	  T#   + '       g   i     Le; i  \         dL    \        TR4      ;_uu_ 4       p\        P                  ! T4      pRRR4        K    + '       g   i      L; ii ; i)z6Low-level function to load metadata from specific filerNrbblocks)
openjsonloadr   picklevalues
isinstancegetlistset)r   r    floadedcs   &&   r   _loadCacheMetadata._load7   s    	(b#!1 
 A!%%/400!!H+.( !   	(b$1Q  	(sE   B B
B 
B	B B C3<CC3C/)C3/C3c               $    V ^8  d   QhRRRRRR/# )r   metadata_to_saver   r    r!   r"   Noner   )r   s   "r   r   r   D   s!     / /f /# /$ /r   c                J   V P                   '       d5   \        V4      ;_uu_ 4       p\        P                  ! W4       RRR4       R# \        VRR7      ;_uu_ 4       p\        P                  ! W4       RRR4       R#   + '       g   i     R# ; i  + '       g   i     R# ; i)z4Low-level function to save metadata to specific fileNw)mode)r   r   r*   dumpr(   )r   r6   r    r0   s   &&& r   _saveCacheMetadata._saveD   sn    """b!!Q,0 "! bs++q		*. ,+ "!! ,++s   A=B=B	B"	c                    V ^8  d   QhRRRR/# )r   writable_onlyboolr"   zIterator[tuple[str, str, bool]]r   )r   s   "r   r   r   M   s      D D!D	(Dr   c              #     "   \        V P                  4      p\        V P                  4       FF  w  r4W2^,
          8H  pV'       d   V'       g   K"  \        P                  P                  VR4      WE3x  KH  	  R# 5i)zYield locations (filenames) where metadata is stored, and whether
writable or not.

Parameters
----------
writable: bool
    Set to True to only yield writable locations.

Returns
-------
Yields (str, str, bool)
cacheN)lenr   	enumerateospathjoin)r   r?   nir   writables   &&    r   _scan_locationsCacheMetadata._scan_locationsM   sW      #DMM2JAEzHX'',,w0'CC	 3s   A
A9,A9c               $    V ^8  d   QhRRRRRR/# )r   rF   r!   cfszCachingFileSystem | Noner"   z#Literal[False] | tuple[Detail, str]r   )r   s   "r   r   r   c   s$      6	,r   c                L   \        V P                  4       V P                  4       F  w  w  r4rVW9  d   K  Wa,          P                  4       pVe   VP                  '       d*   VR,          VP
                  P                  V4      8w  d   Ke  VP                  '       d5   \        P                  ! 4       VR,          ,
          VP                  8  d   K  \        P                  P                  WGR,          4      p\        P                  P                  V4      '       g   K  Ws3u # 	  R# )zIf path is in cache return its details, otherwise return ``False``.

If the optional CachingFileSystem is specified then it is used to
perform extra checks to reject possible matches, such as if they are
too old.
uidtimer    F)ziprK   r   copycheck_filesfsukeyexpiryrQ   rE   rF   rG   exists)r   rF   rN   r    base_rB   details   &&&     r   
check_fileCacheMetadata.check_filec   s     %((<(<(>@Q@Q$R MRq [%%'F???ve}D8I'I:::$))+v">"Kd4L1Bww~~b!!z! %S  r   c                    V ^8  d   QhRRRR/# )r   expiry_timeintr"   ztuple[list[str], bool]r   )r   s   "r   r   r   ~   s     3 3 31G 3r   c                   . pV P                   R,          P                  4       P                  4        F  w  r4\        P                  ! 4       VR,          ,
          V8  g   K/  VP	                  RR4      pV'       g   \        RV 24      h\        P                  P                  V P                  R,          V4      pVP                  V4       V P                   R,          P                  V4       K  	  V P                   R,          '       dU   \        P                  P                  V P                  R,          R4      pV P                  V P                   R,          V4       V P                   R,          '       * pW'3# )zRemove expired metadata from the cache.

Returns names of files corresponding to expired metadata and a boolean
flag indicating whether the writable cache is empty. Caller is
responsible for deleting the expired files.
rQ   r     z)Cache metadata does not contain 'fn' for rB   )r   rS   itemsrQ   r-   RuntimeErrorrE   rF   rG   r   appendpopr<   )r   r_   expired_filesrF   r[   r    
cache_pathwritable_cache_emptys   &&      r   clear_expiredCacheMetadata.clear_expired~   s      --b1668>>@LDyy{VF^+k9ZZb)&CD6J  WW\\$--"3R8$$R(!!"%))$/ A R  dmmB&7AJJJt((,j9#'#4#4R#8822r   c                   V ^8  d   QhRR/# r   r"   r7   r   )r   s   "r   r   r      s     	1 	1d 	1r   c                   . pV P                  4        F_  w  p p\        P                  P                  V4      '       d#   VP	                  V P                  V4      4       KN  VP	                  / 4       Ka  	  T;'       g    / .V n        R# )z>Load all metadata from disk and store in ``self.cached_files``N)rK   rE   rF   rX   rf   r3   r   )r   r   r    rZ   s   &   r   r)   CacheMetadata.load   sk    ,,.HB1ww~~b!!##DJJrN3##B' / )00RDr   c               $    V ^8  d   QhRRRRRR/# )r   r0   r   rF   r!   r"   r7   r   )r   s   "r   r   r      s!      c   r   c                    V P                   R,          V,          pVR,          RJd<   \        VR,          4      VP                  ,          VP                  8  d   RVR&   R# R# R# )z{Perform side-effect actions on closing a cached file.

The actual closing of the file is the responsibility of the caller.
r&   TNrc   )r   rC   	blocksizesize)r   r0   rF   r2   s   &&& r   on_close_cached_file"CacheMetadata.on_close_cached_file   sT     b!$'X;d"s1X;'7!++'E'OAhK (P"r   c                    V ^8  d   QhRRRR/# )r   rF   r!   r"   z
str | Noner   )r   s   "r   r   r      s      S Z r   c                   V P                  VR4      pV'       g   R# Vw  r4VP                  V P                  R,          4      '       d5   V P                  R,          P	                  V4       V P                  4        V# \        R4      h)zRemove metadata of cached file.

If path is in the cache, return the filename of the cached file,
otherwise return ``None``.  Caller is responsible for deleting the
cached file.
Nz<Can only delete cached file in last, writable cache locationrc   )r\   
startswithr   r   rg   savePermissionError)r   rF   detailsrZ   r    s   &&   r   pop_fileCacheMetadata.pop_file   st     //$-==r*++b!%%d+IIK
 	 "N r   c                   V ^8  d   QhRR/# rn   r   )r   s   "r   r   r      s     "1 "1d "1r   c                   \        V P                  4       V P                  4       EF  w  w  rr4V'       g   K  \        P                  P                  V4      '       d   V P                  V4      pVP                  4        F  w  rgWd9   g   K  VR,          RJ g   WF,          R,          RJ d   RVR&   M+WF,          R,          pVP                  VR,          4       WR&   \        VR,          WF,          R,          4      VR&   WF,          R,          VR&   K  	  VP                  4        F  w  rgWe9  g   K  WuV&   K  	  MTpVP                  4        UU	u/ uF  w  riWiP                  4       bK  	  ppp	VP                  4        F7  p\        VR,          \        4      '       g   K"  \        VR,          4      VR&   K9  	  V P                  WA4       WPP                  R&   EK  	  R# u up	pi )zSave metadata to diskr&   TrQ   rP   Nrc   )rR   rK   r   rE   rF   rX   r3   rd   updatemaxrS   r+   r,   r/   r.   r<   )
r   r    rZ   rJ   rB   r   kr2   r&   vs
   &         r   rz   CacheMetadata.save   s   (+D,@,@,BDDUDU(V$RHww~~b!!#zz"~(..0DAzX;$.%(82D2L*.AhK &+Xh%7F"MM!H+6*0hK$'&	58F3C$D&	#(8E?% 1  "KKMDA,*+Q *  %-9-?-?-AB-ATQQ[-AEB\\^ak3//"&q{"3AhK $ JJu!$0b!A )W6 Cs   Gc               $    V ^8  d   QhRRRRRR/# )r   rF   r!   r[   r   r"   r7   r   )r   s   "r   r   r      s!     - - -V - -r   c                0    W P                   R,          V&   R# )z8Update metadata for specific file in memory, do not saveNrc   )r   )r   rF   r[   s   &&&r   update_fileCacheMetadata.update_file   s    &,"d#r   )r   r   r   N)F)__name__
__module____qualname____firstlineno____doc__r   r3   r<   rK   r\   rk   r)   ru   r}   rz   r   __static_attributes__r   r   r   r   r      sE    (&/D,634	1("1H- -r   r   )__conditional_annotations__
__future__r   rE   r*   rQ   typingr   fsspec.utilsr   ujsonr(   ImportErrorcollections.abcr   r   r   r	   cachedr
   dictr!   r   __annotations__r   )r   s   @r   <module>r      sj    " " 	     %
 (..)S#XFI&N- N-  s   A" "A81A87A8