
    +j              	           S SK r S\ R                  S\4S jrSS\S\S\\\4   4S jjrS\S-  S	\S-  S\ R                  S\4S
 jrS\S\4S jr	S\S\
\   4S jrg)    Nstat_resultreturnc                 H    [        U S[        U R                  S-  5      5      $ )z0Extract mtime in nanoseconds from a stat result.st_mtime_nsi ʚ;)getattrintst_mtime)r   s    >/home/wildlama/comfy/ComfyUI/app/assets/services/file_utils.pyget_mtime_nsr      s&    ]C(<(<}(L$M     pathfollow_symlinksc                 X    [         R                  " XS9nUR                  [        U5      4$ )z0Get file size in bytes and mtime in nanoseconds.)r   )osstatst_sizer   )r   r   sts      r
   get_size_and_mtime_nsr      s$    		7B::|B'''r   mtime_dbsize_dbc                     U c  g[        U5      n[        U 5      [        U5      :w  a  gUb!  [        UR                  5      [        U5      :H  $ g)zCheck if a file is unchanged based on mtime and size.

Returns True if the file's mtime and size match the database values.
Returns False if mtime_db is None or values don't match.

size_db=None means don't check size; 0 is a valid recorded size.
FT)r   r   r   )r   r   r   actual_mtime_nss       r
   verify_file_unchangedr      sN     ";/O
8}O,,;&&'3w<77r   namec                 .    U R                  S5      (       + $ )z@Return True if a file or directory name is visible (not hidden)..)
startswith)r   s    r
   
is_visibler   '   s    s###r   base_dirc           
          / n[         R                  R                  U 5      n[         R                  R                  U5      (       d  U$ [	        5       n[         R
                  " USSS9 H  u  pEn [         R                  " U5      nUR                  UR                  4nX;   a  UR                  5         ML  UR                  U5        U V	s/ s H  n	[        U	5      (       d  M  U	PM     sn	USS& U H`  n
[        U
5      (       d  M  UR                  [         R                  R                  [         R                  R                  XJ5      5      5        Mb     M     U$ ! [         a    UR                  5          GM  f = fs  sn	f )z>Recursively list all files in a directory, following symlinks.T)topdownfollowlinksN)r   r   abspathisdirsetwalkr   st_devst_inoOSErrorclearaddr   appendjoin)r   outbase_abs	seen_dirsdirpathsubdirs	filenamesr   dir_iddr   s              r
   list_files_recursivelyr6   ,   s    Cwwx(H77==""
&)eI')ww$D(#)	!Bii+F MMOf!(:AJqMa:
Dd##JJrwwrww||G'BCD ($ J  	MMO	 ;s   /.E	E;!E;E87E8)T)r   r   r   r   strbooltupler   r   r   listr6    r   r
   <module>r<      s    	bnn  ( (d (eCQTHo (Dj4Z  
	,$S $T $
S T#Y r   