+
    ‚°ñj\«  ã                   óÀ  € 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HtHtHt ^ RIt^ RIt^ RIHtHt ^ RIHt ^ RIHt ^ R	IHtHtHt ^ R
I H!t!H"t"H#t#H$t$ ^ RI%H&t&H't' ^ RI(H)t)H*t*H+t+H,t,H-t-H.t.H/t/ ^ RI0H1t1 ^ RI2H3t3H4t4H5t5H6t6H7t7H8t8H9t9H:t: ^ RI;H<t<H=t=H>t>H?t?H@t@HAtA ^ RIBHCtCHDtDHEtEHFtFHGtGHHtHHItI ^ RIJHKtK ^ RILHMtM ^ RINHOtOHPtP ^ RIQHRtRHStSHTtT ^ RIUHVtV ^ RIWHXtXHYtY . RkOtZ]Rl,          t[ ! R R]4      t\ ! R R]4      t]]! RRR7       ! R R4      4       t^ ! R R ]4      t_]. ]`3,          taR! R" ltbR#tcR$tdR%te^tfR&tgR' R( lthR) R* ltiR+ R, ltjR- R. ltkR/ R0 ltlR1 R2 ltmRmR3 R4 lltnR5 R6 ltoR7 R8 ltpR]b3R9 R: lltqR]b3R; R< lltr]b3R= R> lltsR? R@ lttR]b3RA RB lltuRC RD ltvRE RF ltwRmRG RH lltxRI RJ lty ! RK RL]Pô                  4      t{RM RN lt|R]b3RO RP llt}RQ RR lt~RR]b3RS RT llt] ! RU RV4      4       t€ ! RW RX]4      t�RmRY RZ llt‚RnR[ R\ lltƒR] R^ lt„RmR_ R` llt…Ra Rb lt†RoRc Rd llt‡RpRe Rf lltˆRqRg Rh llt‰RrRi Rj lltŠR# )sak  Walks the asset roots and turns what it finds into catalog rows: collecting
paths, building specs, seeding new content and records, then enriching them
with metadata and hashes. Each spec is seeded inside its own savepoint, so one
file whose row conflicts cannot discard the work done for the files around it.
Enrichment candidates use ordered ID pagination, so each row is attempted at
most once per pass while failed rows remain eligible for the next pass. A pause
can end a batch early, and the cursor holds at the last row the batch attempted,
so the rows it never reached are selected again when the scan resumes.
N)Ú	dataclass)Úislice)ÚPath)ÚCallableÚLiteralÚ
NamedTupleÚProtocolÚ	TypedDict)ÚIntegrityErrorÚOperationalError)ÚSession)Úmode)ÚemitÚ
error_kindÚ
error_type)Úcreate_content_reporting_insertÚis_live_path_conflictÚmark_contents_missingÚcreate_record)ÚAssetÚAssetContent)ÚPREFIX_BATCH_SIZEÚmtime_ns_to_utcÚpath_prefix_matcherÚsql_path_under_prefixÚsql_path_under_prefix_batchesÚstored_path_under_prefixesÚto_stored_hash)Úget_excluded_scan_roots)Úclear_pending_verificationsÚdetect_content_changeÚdrain_pending_verificationsÚlive_contents_under_prefixesÚmissing_content_ids_by_pathÚpending_recovery_countÚrecover_missing_contentÚrecover_missing_content_by_stat)ÚPARTIAL_DOWNLOAD_EXTENSIONSÚ_WATCH_LISTÚ_WatchEntryÚ_should_skip_extensionÚ_two_stat_admitÚtick_watch_list)ÚRESCAN_YIELD_RUNÚDirListingsÚListingWalkÚget_mtime_nsÚ
is_visibleÚlist_files_recursivelyÚwalk_listings)Ú	yield_gil)Úextract_media_metadata)ÚExtractedMetadataÚextract_file_metadata)Úcompute_loader_pathÚget_comfy_models_foldersÚ!get_name_and_tags_from_asset_path)Úsnapshot_hash)Úcreate_sessionÚcreate_write_sessionc                   ó>   a € ] tR t^]t o V 3R lR ltV 3R ltRtV tR# )Ú_ScanProgressc                ó&   <€ V ^8„  d   QhRS[ RS[/# )é   ÚkeyÚreturn©ÚstrÚbool)ÚformatÚ__classdict__s   "€Ú6C:\Ai_Coding\apps\studio\ComfyUI\app\assets\scanner.pyÚ__annotate__Ú_ScanProgress.__annotate__f   s   ø€ ×1Ñ1¡Ð1©Ñ1ó    c                ó   € R # ©N© )ÚselfrB   s   &&rI   Úmark_emittedÚ_ScanProgress.mark_emittedf   s   € ©crL   c                ón   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   # )rA   Úhash_failedÚenrich_failedÚpermission_deniedÚmissing_markedÚ	recoveredÚdirs_listedÚfiles_statted©Úint)rG   rH   s   "€rI   rJ   rK   ]   s[   ø‡ ‚ ÙÑñ áÑñ ñ Ññ ñ Ññ	 ñ
 �Nñ ñ Ññ ñ Ñò rL   rO   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rQ   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©rH   s   @rI   r?   r?   ]   s   ø‡ € ÷ 2Ð1÷ ƒ rL   r?   c                   ó,   a € ] tR t^it o V 3R ltRtV tR# )ÚSeedAssetSpecc                óÎ   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[ ;R&   S[S[ ,          ;R&   S[ R,          ;R&   S[R,          ;R&   S[ R,          ;R	&   S[ R,          ;R
&   # )rA   Úabs_pathÚ
size_bytesÚmtime_nsÚ	info_nameÚtagsNÚfnameÚmetadataÚ	mime_typeÚjob_id)rE   r\   Úlistr6   )rG   rH   s   "€rI   rJ   ÚSeedAssetSpec.__annotate__i   sˆ   ø‡ ‚ á�Mñ ñ �Oñ	 ñ
 �Mñ ñ �Nñ ñ ‰s�)�Oñ ñ ��:Ññ ñ   $Õ&Ñ&ñ ñ �T�zÑñ ñ �$�JÑò rL   rO   N©r]   r^   r_   r`   ra   rb   rc   rd   s   @rI   rf   rf   i   ó   ø‡ ‡ „ rL   rf   T)ÚfrozenÚslotsc                   ó,   a € ] tR t^wt o V 3R ltRtV tR# )ÚUnenrichedContentc                ó>   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   # )rA   Ú
content_idÚ	record_idÚ	file_path)rE   )rG   rH   s   "€rI   rJ   ÚUnenrichedContent.__annotate__w   s'   ø‡ ‚ á�Oñ ñ �Nñ ñ �Nò	 rL   rO   Nrs   rd   s   @rI   rx   rx   w   rt   rL   rx   c                   ó0   a € ] tR t^~t o RtV 3R ltRtV tR# )Ú_ReferenceObservationzóOne live row's file, stat'ed outside the write transaction.

``size_bytes`` and ``mtime_ns`` are the row's values when observed, not the file's:
the write skips a row that no longer matches them. ``stat_result`` is None when the
file is gone.
c                óˆ   <€ V ^8„  d   Qh/ S[ ;R&   S[R,          ;R&   S[R,          ;R&   S[P                  R,          ;R&   # )rA   rz   Nri   rj   Ústat_result)rE   r\   Úosr�   )rG   rH   s   "€rI   rJ   Ú"_ReferenceObservation.__annotate__~   sI   ø‡ ‚ ñ �Oñ ñ �d•
Ññ ñ �D�jÑñ ñ —‘ $Õ&Ñ&ò rL   rO   N©r]   r^   r_   r`   Ú__doc__ra   rb   rc   rd   s   @rI   r   r   ~   s   ø‡ € ñ÷ ƒ rL   r   c                ó$   € V ^8„  d   QhR\         /# ©rA   rC   )rF   )rG   s   "rI   rJ   rJ   �   s   € ÷ ñ ”Tñ rL   c                  ó   € R # )FrO   rO   rL   rI   Ú_never_stopr‰   �   s   € ÙrL   é   g{®Gáz”?gš™™™™™¹?gš™™™™™É?c          
      ó�   € V ^8„  d   QhR\         R\        \        \         .\        3,          R\        R\         \        ,          RR/# )rA   ÚitemsÚwrite_batchÚshould_stopÚ	committedrC   N)rq   r   r   r\   Ú
ShouldStop)rG   s   "rI   rJ   rJ       sS   € ÷ !Yñ !YÜð!Yäœ7¤D˜/¬3Ð.Õ/ð!Yô ð!Yô ”C�yð	!Yð
 
ñ!YrL   c                ó’  € \        ^ \        V 4      \        4       Fü  p\        \        4       Fj  pV! 4       '       d     R# \        P
                  ! 4       p \        4       ;_uu_ 4       pV! WpWD\        ,            4      pVP                  4        RRR4        M	  VP                  X4       \        P
                  ! 4       X,
          p
V\        ,           \        V 4      8  g   KÊ  \        P                  ! \!        \#        V
\$        4      \&        4      4       Kþ  	  R#   + '       g   i     L–; i  \         dŒ   p	\        T	P                  \        P                  4      '       d-   \        T	P                  4      R8w  g   T\        ^,
          8X  d   h \        P                  ! \        T^,           ,          4        Rp	?	EK”  Rp	?	ii ; i)a  Apply ``write_batch`` to ``items`` a batch per transaction, appending the count
each batch reports to ``committed`` once it commits. Retry file-open failures in
a new transaction. A failure leaves the batches before it committed, and
``committed`` says how much they wrote.Nzunable to open database file)ÚrangeÚlenÚWRITE_BATCH_ROWSÚWRITE_MAX_ATTEMPTSÚtimeÚperf_counterr=   Úcommitr   Ú
isinstanceÚorigÚsqlite3rE   ÚsleepÚWRITE_RETRY_SECONDSÚappendÚminÚmaxÚWRITE_YIELD_MIN_SECONDSÚWRITE_YIELD_MAX_SECONDS)rŒ   r�   rŽ   r�   ÚstartÚattemptÚopenedÚsessionÚcountÚexcÚhelds   &&&&       rI   Ú_write_in_batchesrª       s<  € ô �qœ#˜e›*Ô&6Ö7ˆÜÔ/Ö0ˆGÙ�}Š}ÛÜ×&Ò&Ó(ˆFðÜ)×+Ô+¨wÙ'¨°uÔGWÕ?WÐ1XÓY�EØ—N‘NÔ$÷ ,ñ ñ% 1ð& 	×Ñ˜ÔÜ× Ò Ó" VÕ+ˆØÔ#Õ#¤c¨%£jÖ0Ü�JŠJ”sœ3˜tÔ%<Ó=Ô?VÓWÖXó/ 8÷ ,×+ûô $ô @ä" 3§8¡8¬W×-EÑ-E×FÒFÜ˜3Ÿ8™8“}Ð(FÔFØÔ"4°qÕ"8Ô8àä—
’
Ô.°'¸Aµ+Õ>×?Ó?ûð@ús1   ÁD0Á)&D	ÂD0ÄD-Ä(D0Ä0GÄ;A?GÇGc                ó4   € V ^8„  d   QhR\         R\        RR/# )rA   ÚphaseÚerrorrC   N)rE   ÚOSError)rG   s   "rI   rJ   rJ   Ä   s&   € ÷ Sñ Sœ3ð S¤wð S°4ñ SrL   c                 óh   € \        V\        4      '       d   R MRp\        P                  ! RW4       R# )rV   Úos_errorz(Asset scan error: phase=%s error_type=%sN)r™   ÚPermissionErrorÚloggingÚwarning)r¬   r­   r   s   && rI   Ú_log_scan_errorr´   Ä   s*   € ä)¨%´×AÒAÑÀzð ô ‡O‚OÐ>ÀÖRrL   c                óF   € V ^8„  d   QhR\         R\        \        ,          /# ©rA   ÚrootrC   )ÚRootTyperq   rE   )rG   s   "rI   rJ   rJ   Ë   s   € ÷ 
ñ 
¤Xð 
´$´sµ)ñ 
rL   c                 ó²  € V R 8X  dW   . p\        4        F  w  r#pVP                  V4       K  	  V Uu. uF"  p\        P                  P	                  V4      NK$  	  up# V R8X  d4   \        P                  P	                  \
        P                  ! 4       4      .# V R8X  d4   \        P                  P	                  \
        P                  ! 4       4      .# . # u upi ©ÚmodelsÚinputÚoutput)r9   Úextendr‚   ÚpathÚabspathÚfolder_pathsÚget_input_directoryÚget_output_directory)r·   ÚbasesÚ_bucketÚpathsÚ_extsÚps   &     rI   Úget_scan_prefixes_for_rootrÉ   Ë   s§   € ØˆxÔØˆÜ%=Ö%?Ñ!ˆG˜EØ�L‰L˜Öñ &@á,1Ó2©E q”—‘—‘ Ö"©EÑ2Ð2Øˆw„Ü—‘—‘¤× @Ò @Ó BÓCÐDÐDØˆxÔÜ—‘—‘¤× AÒ AÓ CÓDÐEÐEØ€Iùò 3s   ³(Cc                ó:   € V ^8„  d   QhR\         \        ,          /# r‡   ©rq   rE   )rG   s   "rI   rJ   rJ   Ø   s   € ÷ eñ eœD¤�Iñ erL   c                 óì   € Rp V  UUu. uF  p\        V4       F  q"NK  	  K  	  pppV\        4       ,           \        P                  P	                  \
        P                  ! 4       4      .,           # u uppi )zREvery directory an asset may live in; references outside these are marked missing.rº   )rÉ   Úget_temp_prefixesr‚   r¿   rÀ   rÁ   Úget_previews_directory)Ú
scan_rootsr·   rÈ   Úprefixess       rI   Úget_owned_prefixesrÑ   Ø   s]   € à'D€JÙ(ÔS™j�dÔ2LÈTÖ2R¨Q’Ñ2R‘™j€HÑSàÔ'Ó)Õ)¬R¯W©W¯_©_¼\×=`Ò=`Ó=bÓ-cÐ,dÕdÐdùó Ts   ˆA0c                ó:   € V ^8„  d   QhR\         \        ,          /# r‡   rË   )rG   s   "rI   rJ   rJ   à   s   € ÷ ñ œ4¤�9ñ rL   c                  óŽ   € \         P                  P                  \        P                  ! 4       4      p V \        4       9   d   . # V .# rN   )r‚   r¿   rÀ   rÁ   Úget_temp_directoryr   )Útemp_dirs    rI   rÍ   rÍ   à   s6   € Ü�w‰w�‰œ|×>Ò>Ó@ÓA€HØÔ*Ó,Ô,Øˆ	Øˆ:ÐrL   c                ó:   € V ^8„  d   QhR\         \        ,          /# r‡   rË   )rG   s   "rI   rJ   rJ   ç   s   € ÷ ñ œd¤3�iñ rL   c                  óf  € . p \        4        EF=  w  rp \        P                  ! V4      ;'       g    . pT EF  p\        ;QJ d/    R \        T4      P                   4       F  '       d   K   RM$	  RM ! R \        T4      P                   4       4      '       g   Kf  \        P                  ! Y4      pT'       g   K†  \        P                  P                  T4      pRp\        T4      p	T F;  p
T	P                  \        P                  P                  T
4      4      '       g   K9  Rp M	  T'       g   Ký  T P                  T4       EK  	  EK@  	  V #   \         dU     \        P                  ! T4      ^ ,          p ELH  \         d%   p\
        P                  ! RY4        Rp? EKš  Rp?ii ; ii ; i)é    z>Asset scan: skipping model category %s, it can't be listed: %sNc              3   ó8   "  € T F  p\        V4      x € K  	  R # 5irN   )r1   )Ú.0Úparts   & rI   Ú	<genexpr>Ú'collect_models_files.<locals>.<genexpr>õ   s   é € ÐIÑ4H¨D”z $×'Ð'Ó4Hùs   ‚FT)r9   rÁ   Úget_filename_listr®   Úget_filename_list_r²   r³   Úallr   ÚpartsÚget_full_pathr‚   r¿   rÀ   Úis_relative_torž   )ÚoutÚfolder_namerÄ   rÇ   Ú	rel_filesÚeÚrel_pathrh   ÚallowedÚabs_pÚbs              rI   Úcollect_models_filesrì   ç   sI  € Ø€CÜ%=×%?Ñ!ˆ˜Eð		Ü$×6Ò6°{ÓC×IÐIÀrˆIô "ˆHß“3ÑI´D¸³N×4HÒ4HÓI—3—3’3ÑI´D¸³N×4HÒ4HÓI×IÒIÙÜ#×1Ò1°+ÓHˆHßÙÜ—w‘w—‘ xÓ0ˆHØˆGÜ˜“NˆEÛ�Ø×'Ñ'¬¯©¯©¸Ó(:×;Ô;Ø"�GÙñ ÷ ‰wØ—
‘
˜8×$ô "ñ &@ð4 €Jøô/ ô 	ðÜ(×;Ò;¸KÓHÈÕK“	øÜô Ü—’Ð `ÐbmÔqßûðúð	ús4   •E²EÅF0ÅE=Å=F,ÆF'ÆF0Æ'F,Æ,F0c                óº   € V ^8„  d   QhR\         R\        \        ,          R\        R,          R\        \        \
        ,          \        \        ,          3,          /# )rA   r¦   rÐ   ÚprogressNrC   )r   rq   rE   r?   Útupler   Úset)rG   s   "rI   rJ   rJ     sI   € ÷ ##ñ ##Üð##Ü $¤S¥	ð##Ü5BÀTÕ5Ið##ä
Œ4Ô%Õ&¬¬C­Ð0Õ1ñ##rL   c           
     ót  € \        W4       Uu. uF1  pVP                  VP                  VP                  VP                  3NK3  	  pp. p\        4       pV F˜  w  rxršVe   V;P                  ^,          un         \        P                  ! VRR7      pVP                  \        P                  P                  V4      4       VP                  V
8w  d   VP                  \        WyW«4      4       K˜  Kš  	  WV3# u upi   \        \        3 d!    TP                  \        YyT
R4      4        KÔ  \          dM   p\#        RT4       Te   T;P$                  ^,          un        \&        P(                  ! RT4        Rp?EK%  Rp?i\*         d0   p\#        RT4       \&        P(                  ! RYŒ4        Rp?EK]  Rp?ii ; i)z¨Stat every live row under ``prefixes`` without writing, so the caller can
apply the result in a short write transaction. Also returns the paths whose
file still exists.NT©Úfollow_symlinksÚreference_statzPermission denied accessing %szOSError checking %s: %s)r"   Úidr¿   ri   rj   rð   rZ   r‚   ÚstatÚaddrÀ   Úst_mtime_nsrž   r   ÚFileNotFoundErrorÚNotADirectoryErrorr±   r´   rV   r²   Údebugr®   )r¦   rÐ   rî   ÚcontentÚcontentsÚobservationsÚ	survivorsrz   r¿   ri   rj   r�   rç   s   &&&          rI   Ú observe_references_on_filesystemr     s|  € ô 4°GÔFóáFˆGð 
�‰�W—\‘\ 7×#5Ñ#5°w×7GÑ7GÓHÙFð ð ð 13€LÜ›%€IÛ2:Ñ.ˆ
˜*ØÒØ×"Ò" aÕ'Õ"ð	ÜŸ'š' $¸Ô=ˆKð �M‰Mœ"Ÿ'™'Ÿ/™/¨$Ó/Ô0Ø×&Ñ&¨(Ô2Ø×#Ñ#Ü)¨*À(ÓXöñ 3ñ' 3;ð. Ð"Ð"ùò;øô "Ô#5Ð6ô 	_Ø×ÑÔ 5°jÈhÐX\Ó ]×^Üô 	BÜÐ,¨aÔ0ØÒ#Ø×*Ò*¨aÕ/Õ*Ü�MŠMÐ:¸D×AÓAûÜô 	>ô Ð,¨aÔ0Ü�MŠMÐ3°T×=Ó=ûð		>ús<   Ž7C4Á9C9Ã9-F7Ä)F7Ä2F7Ä3A E:Å:F7ÆF7Æ#F2Æ2F7c                óR   € V ^8„  d   QhR\         R\        \        ,          R\        /# )rA   r¦   rþ   rC   )r   rq   r   r\   )rG   s   "rI   rJ   rJ   ,  s*   € ÷ 5ñ 5Üð5Ü$(Ô)>Õ$?ð5äñ5rL   c                óÂ  € \        T P                  \        P                  ! \        4      P                  \        P                  P                  V Uu. uF  q"P                  NK  	  up4      4      4      4       . pV FÈ  pV P                  \        VP                  4      pVeI   VP                  '       g7   VP                  VP                  8w  g   VP                  VP                  8w  d   Kq  VP                  f   VP                  VP                  4       Kœ  \        V VVP                  \         P"                  ! 4       R7       KÊ  	  \%        \'        W4      4      # u upi )zBApply the observations; returns how many rows were marked missing.©Úhashing_is_enabled)rq   ÚscalarsÚsaÚselectr   Úwhererõ   Úin_rz   ÚgetÚ
is_missingri   rj   r�   rž   r    r   Úhashing_enabledr“   r   )r¦   rþ   ÚoÚgoneÚobservationrü   s   &&    rI   Úapply_reference_observationsr  ,  s  € ô
 	ˆ�‰œŸš¤<Ó0×6Ñ6´|·±×7JÑ7JÑbnÓKoÑbnÐ]^ÏLÌLÑbnÑKoÓ7pÓqÓ	rÔsØ€DÛ#ˆØ—+‘+œl¨K×,BÑ,BÓCˆð ŠOØ×!×!Ð!Ø×!Ñ! [×%;Ñ%;Ô;Ø×Ñ ;×#7Ñ#7Ô7áØ×"Ñ"Ò*Ø�K‰K˜Ÿ
™
Ô#ÙÜØØØ×#Ñ#Ü#×3Ò3Ó5÷		
ñ $ô& Ô$ WÓ3Ó4Ð4ùò+ Lps   ÁEc                ó¤   € V ^8„  d   QhR\         \        ,          R\        R,          R\        R\         \        ,          R\
        \        ,          /# )rA   rÐ   rî   NrŽ   ÚmarkedrC   )rq   rE   r?   r�   r\   rð   )rG   s   "rI   rJ   rJ   I  sK   € ÷ ñ Ü”3�iðä˜dÕ"ðô ðô ”�Ið	ô
 	Œ…XñrL   c                ó    € \        4       ;_uu_ 4       p\        W@V4      w  rVRRR4       \        X\        W#4       X#   + '       g   i     L#; i)z“Returns the surviving paths; ``marked`` gets each committed batch's count of rows
marked missing, which a caller still has if a later batch raises.N)r<   r   rª   r  )rÐ   rî   rŽ   r  r¦   rþ   rÿ   s   &&&&   rI   Ú_sync_prefixesr  I  sD   € ô 
×	Ô	˜WÜ"BØ˜xó#
Ñˆ÷ 
ô �lÔ$@À+ÔVØÐ÷ 
×	ús	   “=½A	c          	      ól   € V ^8„  d   QhR\         R\        R,          R\        R\        \        ,          /# )rA   r·   rî   NrŽ   rC   )r¸   r?   r�   rð   rE   )rG   s   "rI   rJ   rJ   Y  s9   € ÷ ñ Ü
ðä˜dÕ"ðô ðô 	Œ…Xñ	rL   c           	     ó8  € . p \        \        V 4      WV4      pVe#   V;P                  \        V4      ,          un	        V#   \         dM   p\        P                  ! RY4       \        RT \        T4      \        T4      R7       \        4       p Rp?LzRp?ii ; i)zrSync a single root's references with the filesystem.

Returns survivors (existing paths) or empty set on failure.
úfast DB scan failed for %s: %súscanner.fast_scan_failed©r·   r   r   N)r  rÉ   Ú	Exceptionr²   Ú	exceptionr   r   r   rð   rW   Úsum)r·   rî   rŽ   r  rÿ   r¨   s   &&&   rI   Úsync_root_safelyr  Y  s�   € ð €FðÜ"Ü& tÓ,¨hÀVó
ˆ	ð ÒØ×Ò¤3 v£;Õ.ÕØÐøô ô Ü×ÒÐ:¸DÔFÜØ&ØÜ! #“Ü! #“õ		
ô “E�	ûðús   „A ÁBÁABÂBc                óB   € V ^8„  d   QhR\         R,          R\        RR/# )rA   rî   NrŽ   rC   )r?   r�   )rG   s   "rI   rJ   rJ   u  s+   € ÷ 
ñ 
Ü˜dÕ"ð
äð
ð 
ñ
rL   c           	     óÔ   €  \        \        4       W. 4       R#   \         dD   p\        P                  ! RT4       \        RR\        T4      \        T4      R7        Rp?R# Rp?ii ; i)z]Retire temp references whose file is gone; temp is never scanned, so nothing else stats them.ztemp reference sync failed: %szscanner.temp_sync_failedÚtempr  N)r  rÍ   r  r²   r  r   r   r   )rî   rŽ   r¨   s   && rI   Úsync_temp_references_safelyr!  u  sY   € ð
	
ÜÔ(Ó*¨HÀ2ÖFøÜô 
Ü×ÒÐ:¸CÔ@ÜØ&ØÜ! #“Ü! #“÷		
ó 	
ûð
ús   ‚ ™A'¤8A"Á"A'c                ó`   € V ^8„  d   QhR\         \        ,          R\        R\        R,          /# )rA   rÐ   rŽ   rC   N)rq   rE   r�   r\   )rG   s   "rI   rJ   rJ   †  s,   € ÷ ñ Ü”3�iðÜ&0ðäˆ4…ZñrL   c                ób  € . p \        4       ;_uu_ 4       p\        W04      pRRR4       \        XR VV4       \        V4      #   + '       g   i     L*; i  \         dM   p\
        P                  ! R\        T4      T4       \        R\        T4      \        T4      R7        Rp?R# Rp?ii ; i)zÓMark references as missing when outside the given prefixes.

This is a non-destructive soft-delete. Returns the count marked, or None when
the operation fails; batches committed before a failure stay committed.
Nc                 ó*   € \        \        W4      4      # rN   )r“   r   )r¦   Úbatchs   &&rI   Ú<lambda>Ú6mark_missing_outside_prefixes_safely.<locals>.<lambda>”  s   € ¤3Ô'<¸WÓ'LÔ#MrL   z2marking missing assets failed after marking %d: %szscanner.mark_missing_failed)r   r   )
r<   Úcontent_ids_outside_prefixesrª   r  r  r²   r  r   r   r   )rÐ   rŽ   r  ÚsessÚcontent_idsr¨   s   &&    rI   Ú$mark_missing_outside_prefixes_safelyr+  †  s›   € ð €FðÜ×Ô Ü6°tÓFˆK÷ äØÙMØØô		
ô �6‹{Ð÷ ×ûô ô Ü×ÒÐNÔPSÐTZÓP[Ð]`ÔaÜØ)Ü! #“Ü! #“õ	
õ
 ûðús.   „A –A¢!A ÁA	ÁA ÁB.Á"AB)Â)B.c                óh   € V ^8„  d   QhR\         R\        \        ,          R\        \        ,          /# )rA   r¦   rÐ   rC   )r   rq   rE   )rG   s   "rI   rJ   rJ   £  s/   € ÷ 	Kñ 	K¬'ð 	K¼TÄ#½Yð 	KÌ4ÔPSÍ9ñ 	KrL   c                óz  € \        V4      pV P                  \        P                  ! \        P
                  \        P                  4      P                  \        P                  \        P                  ! 4       8H  4      P                  RR7      4      pV UUu. uF  w  rEV! V4      '       d   K  VNK  	  upp# u uppi )zvThe live rows outside every prefix. A read: the marking re-checks each is still
live inside its own write transaction.éô  ©Ú	yield_per)r   Úexecuter  r  r   rõ   r¿   r  r  ÚfalseÚexecution_options)r¦   rÐ   Úis_ownedÚrowsrz   r¿   s   &&    rI   r(  r(  £  s‚   € ô # 8Ó,€HØ�?‰?Ü
�	Š	”,—/‘/¤<×#4Ñ#4Ó5ß	‰Œ|×&Ñ&¬"¯(ª(«*Ñ4Ó	5ß	Ñ	 SÐ	Ó	)ó€Dñ
 04ÔJ©tÑ+˜:¹8ÀD¿>�JˆJ©tÒJÐJùÓJs   ÂB7Â-B7c          	      ó†   € V ^8„  d   QhR\         \        R3,          R\        R,          R\        R\        \
        ,          /# )rA   Úroots.rî   NrŽ   rC   )rï   r¸   r?   r�   rq   rE   )rG   s   "rI   rJ   rJ   ¯  sB   € ÷ ñ Ü”˜3�Õðä˜dÕ"ðô ðô 
Œ#…Yñ	rL   c                ó  € . pRV 9   d   VP                  \        4       4       RV 9   d/   VP                  \        \        P                  ! 4       W4      4       RV 9   d/   VP                  \        \        P
                  ! 4       W4      4       V# )a´  Collect all file paths for the given roots.

``progress.dirs_listed`` counts the input and output walks only. Models are
listed through folder_paths.get_filename_list, which walks the model folders
on a cache miss and re-checks their mtimes on a hit; none of that is counted.

``should_stop`` is checked before each input or output directory; once it returns
True the list is partial, so callers check it again before using the result.
r»   r¼   r½   )r¾   rì   r2   rÁ   rÂ   rÃ   )r7  rî   rŽ   rÆ   s   &&& rI   Úcollect_paths_for_rootsr9  ¯  sr   € ð €EØ�5ÔØ�‰Ô)Ó+Ô,Ø�%ÔØ�‰Ô+¬L×,LÒ,LÓ,NÐPXÓfÔgØ�5ÔØ�‰Ô+¬L×,MÒ,MÓ,OÐQYÓgÔhØ€LrL   c                óJ   € V ^8„  d   QhR\         \        R3,          R\        /# )rA   r7  .rC   )rï   r¸   rF   )rG   s   "rI   rJ   rJ   Ç  s#   € ÷ 
'ñ 
'¤U¬8°S¨=Õ%9ð 
'¼dñ 
'rL   c                ó   € \        V 4      R8H  # )a&  Whether this scan checks the catalog against directory listings rather than by
stat'ing every live row. Only output-only scans do: the rescan queued after each prompt.

The listing diff catches every add and delete, but nothing stats an already-cataloged
file, so an in-place overwrite (same path; new content, size or mtime) goes undetected
until the next scan that is not output-only, such as the startup scan. Core save nodes
never overwrite, and reported outputs are registered at save time, so this only
affects files written by something else.
)r½   )rï   )r7  s   &rI   Úrescans_output_by_listingr<  Ç  s   € ô �‹<˜;Ñ&Ð&rL   c                óh   € V ^8„  d   QhR\         R\        \        \        \        ,          3,          /# r¶   )r¸   ÚdictrE   rq   r   )rG   s   "rI   rJ   rJ   Ô  s*   € ÷ #ñ #¤ð #¬d´3¼Ô=RÕ8SÐ3SÕ.Tñ #rL   c                ó¨  € \        V 4      p/ pV'       g   V# \        4       p \        4       ;_uu_ 4       p\        \        P
                  V4       EF  p\        P                  ! \        P                  \        P
                  \        P                  \        P                  4      P                  \        P                  P                  R4      V4      pVP                  V4       Fx  w  rxrš\        \         R7       Ws9   d   K  VP#                  V4       VP%                  \&        P
                  P)                  V4      . 4      P+                  \-        WyV
R4      4       Kz  	  EK  	  RRR4       V#   + '       g   i     T# ; i  \.         dE   p\0        P2                  ! RY4       \5        RT \7        T4      \9        T4      R7       / u Rp?# Rp?ii ; i)a	  The live rows under ``root`` by path, read without touching the filesystem.

Each is observed as gone (``stat_result=None``): what apply_reference_observations
needs to retire it, should its path turn out not to be listed. Empty on failure, as
sync_root_safely is.
F©ÚrunNr  r  r  )rÉ   rð   r<   r   r   r¿   r  r  rõ   ri   rj   r  r  Úis_r1  r4   r-   r÷   Ú
setdefaultr‚   rÀ   rž   r   r  r²   r  r   r   r   )r·   rÐ   ÚliveÚseenr¦   Úunder_prefixesÚstmtrz   r¿   ri   rj   r¨   s   &           rI   Úlive_references_safelyrH  Ô  sg  € ô *¨$Ó/€HØ35€DßØˆÜ“U€DðÜ×Ô Ü"?Ä×@QÑ@QÐS[×"\�Ü—y’yÜ —O‘O¤\×%6Ñ%6¼×8OÑ8OÔQ]×QfÑQfóç‘%œ×/Ñ/×3Ñ3°EÓ:¸NÓKð ð ?F¿o¹oÈdÖ>SÑ:�J jÜÔ"2Õ3Ø!Ô)Ù Ø—H‘H˜ZÔ(Ø—O‘O¤B§G¡G§O¡O°DÓ$9¸2Ó>×EÑEÜ-¨jÀhÐPTÓUöô ?Tñ	 #]÷ ð, €K÷- Öð, €Kûô ô Ü×ÒÐ:¸DÔFÜØ&ØÜ! #“Ü! #“õ		
ð �	ûðús;   £F µD/E.Å$F Å.E?	Å9F Å?F ÆGÆ9GÇGÇGc          
      óÆ   € V ^8„  d   QhR\         \        \        \        ,          3,          R\        R\
        R,          R\        \        \        ,          \        3,          /# )rA   rD  Úlistingsrî   NrC   )r>  rE   rq   r   r.   r?   rï   r\   )rG   s   "rI   rJ   rJ   ú  sU   € ÷ ñ Ü
Œs”DÔ.Õ/Ð/Õ
0ðäðô ˜dÕ"ðô Œ4Ô%Õ&¬Ð+Õ,ñ	rL   c                óP  € . p^ p/ pV P                  4        FŠ  w  rg\        \        R7       \        WaV4      pV\        P
                  J d   K7  Ve   V;P                  ^,          un        \        V4      '       d   VP                  V4       Kx  V\        V4      ,          pKŒ  	  W43# )aÂ  Split the live rows into (vanished, skipped count).

A row its parent's listing names is present, with no further check. Every other row
is stat'ed, and has vanished only if the stat says the file is gone: that covers a
name the listing lacks, a removed directory, and the rows no listing can speak for
(a hidden path, a directory that failed to list, a symlink alias the walk did not
take). The skipped count is the rows that were stat'ed and kept.
r@  )
rŒ   r4   r-   Ú_listing_verdictÚListingVerdictÚLISTEDrZ   Ú_is_goner¾   r“   )	rD  rJ  rî   ÚvanishedÚskippedÚnames_by_dirr¿   rþ   Úverdicts	   &&&      rI   Úunlisted_referencesrT  ú  s”   € ð -/€HØ€GØ(*€LØ"Ÿj™jžlÑˆÜÔ&Õ'Ü" 4°<Ó@ˆØ”n×+Ñ+Ó+Ùð ÒØ×"Ò" aÕ'Õ"Ü�D�>Š>Ø�O‰O˜LÖ)à”s˜<Ó(Õ(ŠGñ +ð ÐÐrL   c                ó0   € V ^8„  d   QhR\         R\        /# )rA   r¿   rC   rD   )rG   s   "rI   rJ   rJ     s   € ÷ 	ñ 	”3ð 	œ4ñ 	rL   c                ó~   €  \         P                  ! V 4       R#   \        \        3 d     R# \         d     R# i ; i)zžTrue only when stat says the path does not exist. Any other error (permissions,
I/O) leaves it undecided, and the row stays live, as the per-row stat left it.TF)r‚   rö   rù   rú   r®   )r¿   s   &rI   rO  rO    s<   € ðÜ
�Š�Œñ
 øô	 Ô1Ð2ô ÚÜô Úðús   ‚ š<®<·<»<c                   ó&   € ] tR tRtRtRtRtRtRtR# )rM  i'  zAWhat this rescan's directory listings say about a cataloged path.ÚlistedÚabsentÚunknownrO   N)	r]   r^   r_   r`   r…   rN  ÚABSENTÚUNKNOWNrb   rO   rL   rI   rM  rM  '  s   † ÙKà€FØ€FØ„GrL   rM  c          	      ó€   € V ^8„  d   QhR\         R\        R\        \         \        \         ,          3,          R\        /# )rA   r¿   rJ  rR  rC   )rE   r.   r>  rð   rM  )rG   s   "rI   rJ   rJ   /  s?   € ÷ Nñ NÜ
ðNÜ$ðNÜ48¼¼cÄ#½h¸Õ4GðNäñNrL   c                ó„  € T \         P                  P                  V 4      rCWA9  dw   \        \         P                  P	                  V4      4      '       g   \
        P                  # T\         P                  P                  V4      rCWC8X  g   Kl  \
        P                  # \         P                  P	                  V4      p\        V4      '       g   \
        P                  # VP                  V4      pVf   W,          w  rx0 VmVm;qbV&   WV9  d   \
        P                  # W08X  d   \
        P                  # \
        P                  # )z“Classify ``path`` against the listings; see ListingVerdict. An ancestor that
still has the directory this walk did not list is UNKNOWN, not LISTED.)
r‚   r¿   Údirnamer1   ÚbasenamerM  r\  r
  r[  rN  )	r¿   rJ  rR  ÚchildÚparentÚnameÚnamesÚfilesÚsubdirss	   &&&      rI   rL  rL  /  s÷   € ð
 œ"Ÿ'™'Ÿ/™/¨$Ó/ˆ6Ø
Ô
 Üœ"Ÿ'™'×*Ñ*¨5Ó1×2Ò2Ü!×)Ñ)Ð)Ø¤§¡§¡°Ó 7ˆvØŽ?Ü!×)Ñ)Ð)Ü�7‰7×Ñ˜EÓ"€DÜ�d×ÒÜ×%Ñ%Ð%Ø×Ñ˜VÓ$€EØ‚}Ø!Õ)‰ˆØ'9¨Ð'9°Ð'9Ð9ˆ˜VÑ$ØÔÜ×$Ñ$Ð$Ø$)¤MŒ>× Ñ ÐM´~×7MÑ7MÐMrL   c          
      óp   € V ^8„  d   QhR\         R\        \        ,          R\        R,          R\        RR/# )rA   r·   rþ   rî   NrŽ   rC   )r¸   rq   r   r?   r�   )rG   s   "rI   rJ   rJ   G  sE   € ÷ /ñ /Ü
ð/äÔ,Õ-ð/ô ˜dÕ"ð/ô ð	/ð
 
ñ/rL   c           	     ó  € . p \        V\        W44       Ve%   V;P                  \        V4      ,          un        R# R#   \         dC   p\        P                  ! RY4       \        RT \        T4      \        T4      R7        Rp?LrRp?ii ; i)z|Retire rows whose file the listing lacks, through the same guarded write
sync_root applies to a row whose file has vanished.r  r  r  N)
rª   r  r  r²   r  r   r   r   rW   r  )r·   rþ   rî   rŽ   r  r¨   s   &&&&  rI   Ú'mark_unlisted_references_missing_safelyri  G  s�   € ð €Fð	
Ü˜,Ô(DÀkÔZð ÒØ×Ò¤3 v£;Õ.×ñ øô ô 
Ü×ÒÐ:¸DÔFÜØ&ØÜ! #“Ü! #“÷		
ò 	
ûð
ús   „? ¿BÁ
8BÂBc                ó$   € V ^8„  d   QhR\         /# r‡   )r/   )rG   s   "rI   rJ   rJ   ^  s   € ÷ >ñ >¤ñ >rL   c                 ó>   € \        \        P                  ! 4       4      # )z.Walk the output root, listing every directory.)r3   rÁ   rÃ   rO   rL   rI   Úlist_output_for_rescanrl  ^  s   € äœ×:Ò:Ó<Ó=Ð=rL   c                óò   € V ^8„  d   QhR\         \        ,          R\        \        ,          R\        R\        R,          R\
        R\        \         \        ,          \        \        ,          \        3,          /# )rA   rÆ   Úexisting_pathsÚenable_metadata_extractionrî   NrŽ   rC   )	rq   rE   rð   rF   r?   r�   rï   rf   r\   )rG   s   "rI   rJ   rJ   c  sn   € ÷ Z$ñ Z$Ü”�9ðZ$äœ•HðZ$ô !%ðZ$ô ˜dÕ"ð	Z$ô
 ðZ$ô Œ4”Õ¤¤C¥¬#Ð-Õ.ñZ$rL   c                ó¾  € . p\        4       p^ p. pV  FÇ  p	V! 4       '       d   . \        4       V3u # \        P                  P                  V	4      p
\	        V
4      '       d   V^,          pKZ  W¡9   d   V^,          pKk  Ve   V;P
                  ^,          un         \        P                  ! V
RR7      pTP"                  '       g   Kµ  TP%                  Y«34       KÉ  	  \'        WƒV4      w  rÞ\)        V4      pV F¿  p
V! 4       '       d   . \        4       V3u # \+        4        Wú,          p\-        V
4      w  pp\/        V
4      pRpV'       d   \1        V
VVR	7      pV'       d   VP2                  MRpVP%                  R
V
RVP"                  R\5        V4      RVRVRVRVRVRR/	4       VP7                  V4       KÁ  	  WVV3#   \         d     EK¼  \         d„   p\        RT4       Teh   \        T\        4      '       d   T;P                  ^,          un        TP                  R4      '       d"   \        RR\        T4      \!        T4      R7        Rp?EKD  Rp?ii ; i)aÖ  Build asset specs from paths, returning (specs, tag_pool, skipped_count).

Args:
    paths: List of file paths to process
    existing_paths: Set of paths that already exist in the database
    enable_metadata_extraction: If True, extract tier 1 & 2 metadata
    progress: Optional per-scan state for emit-once bookkeeping
    should_stop: Checked before each path's stats and spec, so a large library
        can pause here; once it returns True, no specs are returned
NTrò   Údiscovery_statzstat_failed:discoveryúscanner.stat_failedÚ	discovery©Úsiter   r   ©r�   Úrelative_filenamerh   ri   rj   rk   rl   rm   rn   ro   rp   )rð   r‚   r¿   rÀ   r*   rZ   rö   rù   r®   r´   r™   r±   rV   rQ   r   r   r   Úst_sizerž   r+   r>  r4   r:   r8   r7   Úcontent_typer0   Úupdate)rÆ   rn  ro  rî   rŽ   ÚspecsÚtag_poolrQ  Ú
candidatesrÈ   rê   Ústat_prç   Úadmitted_pathsÚ_Úcandidate_statsrc  rl   Ú	rel_fnamern   ro   s   &&&&&                rI   Úbuild_asset_specsrƒ  c  s1  € ð" "$€EÜ›€HØ€GØ35€JãˆÙ�=Š=Ø”s“u˜gÐ%Ò%Ü—‘—‘ Ó"ˆÜ! %×(Ò(Ø�q�LˆGÙØÔ"Ø�q�LˆGÙØÒØ×"Ò" aÕ'Õ"ð	Ü—W’W˜U°DÔ9ˆFð  �~�~ˆ~ÙØ×Ñ˜5˜/Ö*ñ? ôB (¨
¸kÓJÑ€NÜ˜:Ó&€OÛˆÙ�=Š=Ø”s“u˜gÐ%Ò%ÜŒØ Õ'ˆÜ6°uÓ=‰
ˆˆdÜ'¨Ó.ˆ	ð ˆß%Ü,ØØ"Ø"+ôˆH÷ .6�H×)Ò)¸4ˆ	Ø�‰à˜EØ˜fŸn™nØœL¨Ó0Ø˜TØ˜Ø˜Ø˜HØ˜YØ˜$ð
ô	
ð 	�‰˜Öñ?  ðB ˜GÐ#Ð#øôm !ô 	ÛÜô 	ÜÐ,¨aÔ0ØÒ#Ü˜a¤×1Ò1Ø×.Ò.°!Õ3Õ.Ø×(Ñ(Ð)@×AÒAÜØ-Ø(Ü#-¨a£=Ü#-¨a£=õ	ö ûð	ús+   ÂG Ç IÇIÇIÇAIÈ/!IÉIc                   ó4   a € ] tR tRt o Rt^ tV 3R ltRtV tR# )Ú
SeedCountsiÀ  z<What one seed_asset_specs call did besides creating records.c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )rA   rX   r[   )rG   rH   s   "€rI   rJ   ÚSeedCounts.__annotate__À  s   ø‡ ‚ ñ Ñò	 rL   rO   N)	r]   r^   r_   r`   r…   rX   ra   rb   rc   rd   s   @rI   r…  r…  À  s   ø‡ € áFà€I÷	 ƒ rL   r…  c                   ó0   a € ] tR tRt o RtV 3R ltRtV tR# )Ú_SpecObservationiÇ  z’A spec's file as seen before the write transaction opens.

``snapshot`` is None when hashing is off, or when the file changed while being hashed.
c                ó~   <€ V ^8„  d   Qh/ S[ P                  ;R&   S[S[S[ P                  3,          R,          ;R&   # )rA   r�   NÚsnapshot)r‚   r�   rï   rE   )rG   rH   s   "€rI   rJ   Ú_SpecObservation.__annotate__Ç  s6   ø‡ ‚ ñ —‘Ññ ñ ‘C™Ÿ™Ð'Õ(¨4Õ/Ñ/ò rL   rO   Nr„   rd   s   @rI   r‰  r‰  Ç  s   ø‡ € ñ÷ ƒ rL   r‰  c          	      ó�   € V ^8„  d   QhR\         \        ,          R\        R,          R\        \        \
        R,          3,          /# )rA   r{  rî   NrC   )rq   rf   r?   r>  rE   r‰  )rG   s   "rI   rJ   rJ   Ñ  s>   € ÷ ñ Ü”ÕðÜ*7¸$Õ*>ðä	Œ#Ô $Õ&Ð
&Õ'ñrL   c                óþ  € \         P                  ! 4       p/ pV  FŽ  p\        P                  P	                  VR,          4      pVe   V;P
                  ^,          un         \        P                  ! VRR7      pV'       d   \        V4      MRpTe
   T^,          p\        Yg4      Y5&   K�  	  V#   \         d     \        P                  ! RT4       RY5&    K½  \         d   p\        RT4       RY5&    Rp?KÝ  Rp?ii ; i)z‹Stat (and, in hashing mode, hash) each spec before the write transaction opens.

``None`` marks a path that vanished or could not be read.
rh   NTrò   z'Skipping vanished asset during scan: %sÚseed_observation)r   r  r‚   r¿   rÀ   rZ   rö   r;   rù   r²   r³   r®   r´   r‰  )	r{  rî   r  ÚobservedÚspecr¿   r�   r‹  rç   s	   &&       rI   Úobserve_asset_specsr’  Ñ  sß   € ô ×-Ò-Ó/ÐØ35€HÛˆÜ�w‰w�‰˜t JÕ/Ó0ˆØÒØ×"Ò" aÕ'Õ"ð
	ÜŸ'š' $¸Ô=ˆKß.@”} TÔ*ÀdˆHð ÒØ" 1�+ˆKÜ)¨+Ó@ˆ‹ñ# ð$ €Oøô !ô 	Ü�OŠOÐEÀtÔLØ!ˆH‰NÚÜô 	ÜÐ.°Ô2Ø!ˆH‰NÝûð	ús*   Á!B.ÂB.Â.&C<ÃC<Ã C<Ã!C7Ã7C<c                ó8  € V ^8„  d   QhR\         R\        \        ,          R\        \        \
        R,          3,          R,          R\        R,          R\        \        \        \        ,          3,          R,          R\        \        \        R,          3,          /# )rA   r¦   r{  r�  NÚcountsÚmissing_ids_by_pathrC   )
r   rq   rf   r>  rE   r‰  r…  rï   r\   r  )rG   s   "rI   rJ   rJ   ï  sŒ   € ÷ W ñ W ÜðW ä”ÕðW ô ”3Ô(¨4Õ/Ð/Õ0°4Õ7ðW ô ˜Õð	W ô
 œc¤4¬¥9˜nÕ-°Õ4ðW ô Œ3”	˜DÕ Ð Õ!ñW rL   c                ód  € Vf   \        V4      p\        P                  ! 4       pV'       g   Vf   \        V \	        V4      4      p^ pRp^ pV EF/  p	\
        P                  P                  V	R,          4      p
 V P                  4       ;_uu_ 4        W*,          pVf    RRR4       K[  VP                  p\        V4      ^ 8  d,   \        P                  ! RV
4       V^,          p RRR4       K¢  V'       d   \        W
VP                  RR7      pM&\        Y
YÄ;'       g    / P!                  V
. 4      4      pVR8X  d   Ve   V;P"                  ^,          un        VR8w  d    RRR4       EK   \%        V V
RVP&                  \        V4      R7      w  rïV P)                  \*        P,                  ! \.        P0                  4      P3                  \.        P4                  VP0                  8H  4      P7                  ^4      4      pVe    RRR4       EKÁ  \9        V VP0                  V	R	,          V	R
,          V	R,          V	R,          V	R,          \;        \        V4      VP<                  4      R7       V^,          pRRR4       EK2  	  V'       d   \G        RVR7       Wg3#   + '       g   i     EK^  ; i  \>         dI   p\A        T4      '       d   \        P                  ! RT
4        Rp?EK›  Tf
   Tp Rp?EK¨   Rp?EK¯  Rp?i\B         d    h \D         d   pTf
   Tp Rp?EKÕ   Rp?EKÜ  Rp?ii ; i)z•``missing_ids_by_path`` is only used with hashing off. insert_asset_specs reads it
before its write transaction opens; when omitted, it is read here.Nrh   z1Skipping asset with invalid mtime during scan: %sTr  rX   Úno_match)r¿   Úhashri   rj   rk   ro   rp   rm   rl   )rz   rc  ro   rp   Úloader_pathrl   Ú
created_atz2Skipping asset whose row conflicts during scan: %szscanner.invalid_mtime)r§   )$r’  r   r  r#   Ú_observed_pathsr‚   r¿   rÀ   Úbegin_nestedr�   r0   r²   r³   r%   r‹  r&   r
  rX   r   rx  Úscalarr  r  r   rõ   r  rz   Úlimitr   r   Úst_ctime_nsr
   r   ÚMemoryErrorr  r   )r¦   r{  r�  r”  r•  r  ÚcreatedÚfirst_errorÚinvalid_mtimesr‘  r¿   r  r�   Úrecoveryrü   Ú	_insertedÚexisting_recordr­   s   &&&&&             rI   Úseed_asset_specsr§  ï  sÎ  € ð ÒÜ& uÓ-ˆÜ×-Ò-Ó/ÐßÐ"5Ò"=Ü9¸'Ä?ÐS[ÓC\Ó]ÐØ€GØ$(€Kð €NÜˆÜ�w‰w�‰˜t JÕ/Ó0ˆð>	$Ø×%Ñ%×'Õ'Ø&�n�ØÒ&Ø÷ (Ñ'ð *×5Ñ5�Ü Ó,¨qÔ0Ü—O’OØKÈTôð # aÕ'�NØ÷ (Ñ'÷ &Ü6Ø {×';Ñ';ÐPTô ‘Hô  ?Ø {×5NÐ5NÈB×4SÑ4SÐTXÐZ\Ó4]ó �Hð ˜{Ô*¨vÒ/AØ×$Ò$¨Õ)Õ$Ø˜zÔ)Ø÷- (Ò'ô. &EØØØØ*×2Ñ2Ü)¨+Ó6ô&Ñ"�ð #*§.¡.Ü—I’IœeŸh™hÓ'×-Ñ-¬e×.>Ñ.>À'Ç*Á*Ñ.LÓM×SÑSÐTUÓVó#�ð #Ò.Ø÷E (Ò'ôF ØØ&Ÿz™zØ˜kÕ*Ø" ;Õ/Ø �>Ø $ W¥Ø˜f�ä.¬|¸KÓ/HÈ+×JaÑJaÓbõ
ð ˜1•�÷] (Ò'ñ ÷B ÜÐ$¨NÕ;ØÐÐ÷A (×'Ñ'ûô^ ô 	$Ü$ U×+Ò+Ü—’ØHÈ$ôö ØÒ"Ø#—ö #ûäô 	ð Üô 	$ØÒ"Ø#—ö #ûð	$ús�   Á9J/ÂJÂJ/Â)=JÃ&J/Ã0JÃ8A+JÅ#J/Å.BJÈJ/ÈA&JÉ5J/ÊJ,Ê%J/Ê,J/Ê/L/Ê:(K=Ë)K=Ë=L/Ì

L/ÌL/ÌL*Ì*L/c                óv   € V ^8„  d   QhR\         \        \        R,          3,          R\        \        ,          /# )rA   r�  NrC   )r>  rE   r‰  rq   )rG   s   "rI   rJ   rJ   I  s2   € ÷ Wñ Wœd¤3Ô(8¸4Õ(?Ð#?Õ@ð WÄTÌ#ÅYñ WrL   c                 ób   € V P                  4        UUu. uF  w  rVf   K  VNK  	  upp# u uppi rN   )rŒ   )r�  r¿   r  s   &  rI   r›  r›  I  s*   € Ø*2¯.©.Ô*:ÔVÑ*:Ñ&�T¸k�DˆDÑ*:ÒVÐVùÓVs   ”+¡+c                ó²   € V ^8„  d   QhR\         \        ,          R\        \        ,          R\        R,          R\
        \        \        R,          3,          /# )rA   r{  Ú	_tag_poolrî   NrC   )rq   rf   rð   rE   r?   rï   r\   r  )rG   s   "rI   rJ   rJ   M  sM   € ÷ $ñ $Ü”Õð$ä”3�xð$ô ˜dÕ"ð$ô Œ3”	˜DÕ Ð Õ!ñ	$rL   c           	      óÜ  € V '       g   R# \        W4      pRp\        P                  ! 4       '       g1   \        4       ;_uu_ 4       p\	        V\        V4      4      pRRR4       \        4       p\        4       ;_uu_ 4       p\        WPW6V4      w  rx VP                  4        Te$   T;P                  TP                  ,          un        Yx3uuRRR4       #   + '       g   i     L�; i  \         df    Tf   h \        P                  ! R4        TP                  4        M'  \         d    \        P                  ! R4        Mi ; i^ T3u uuRRR4       # i ; i  + '       g   i     R# ; i)rØ   Nz9Failed to commit successful specs from failed asset batchz4Failed to roll back asset batch after commit failure)rØ   N)r’  r   r  r<   r#   r›  r…  r=   r§  r˜   r  r²   r  ÚrollbackrX   )	r{  r«  rî   r�  r•  r)  r”  r¡  r¢  s	   &&&      rI   Úinsert_asset_specsr®  M  s.  € ÷
 ØˆÜ" 5Ó3€HØÐÜ×Ò×!Ò!Ü×Ô Ü"=¸dÄOÐT\ÓD]Ó"^Ð÷ ä‹\€FÜ	×	Ô	 4Ü/Ø˜Ð+>ó 
Ñˆð
	"Ø�K‰KŒMð ÒØ×Ò &×"2Ñ"2Õ2ÕØÐ#÷# 
 Ò	÷ ×ûô ô 	"ØÒ"ØÜ×ÒÐYÔZðZØ—‘•øÜô ZÜ×!Ò!Ð"XÖYðZúà�k�>Ñ!÷ 
 Ò	ð	"ú÷ 
 ×	Ð	ús`   ÁCÁ?EÂC'Â )EÃC$	Ã'&EÄDÄEÄ!E	Å EÅE	ÅEÅ
EÅEÅEÅE+	c          
      ó    € V ^8„  d   QhR\         R\        R,          R\        P                  \        \        \        \        3,          ,          /# )rA   Úcompute_hashesÚlast_seen_idNrC   )rF   rE   r  ÚSelectrï   )rG   s   "rI   rJ   rJ   n  s<   € ÷ *ñ *Üð*Ü(+¨d­
ð*ä‡Y�YŒu”Sœ#œs�]Õ#Õ$ñ*rL   c                ó  € \         P                  ! \        P                  \        P                  \        P
                  4      P                  \        \        P                  \        P                  8H  4      P                  \        P                  P                  R4      4      pV '       db   VP                  \         P                  ! \        P                  P                  R4      \        P                  P                  R4      4      4      pM.VP                  \        P                  P                  R4      4      pVe#   VP                  \        P                  V8„  4      pVP                  \        P                  P                  4       4      # )zDEvery unenriched live candidate after ``last_seen_id``, in id order.FN)r  r  r   rõ   r   r¿   Újoinrz   r  r  rB  Úor_r˜  Úsystem_metadataÚorder_byÚasc)r°  r±  Úquerys   && rI   Úunenriched_candidates_queryrº  n  sû   € ô
 	�	Š	”,—/‘/¤5§8¡8¬\×->Ñ->Ó?ß	‰Œe”U×%Ñ%¬¯©Ñ8Ó	9ß	‰Œ|×&Ñ&×*Ñ*¨5Ó1Ó	2ð 
÷
 Ø—‘Ü�FŠFÜ×!Ñ!×%Ñ% dÓ+Ü×%Ñ%×)Ñ)¨$Ó/óó
‰ð —‘œE×1Ñ1×5Ñ5°dÓ;Ó<ˆØÒØ—‘œEŸH™H |Ñ3Ó4ˆØ�>‰>œ%Ÿ(™(Ÿ,™,›.Ó)Ð)rL   c                óÎ   € V ^8„  d   QhR\         \        ,          R\        R\        R,          R\        R\        P
                  \        \        \        \        3,          ,          /# )rA   rÐ   r°  r±  Nrž  rC   )rq   rE   rF   r\   r  r²  rï   )rG   s   "rI   rJ   rJ   …  sV   € ÷ ñ Ü”3�iðäðô ˜•*ðô ð	ô
 ‡Y�YŒu”Sœ#œs�]Õ#Õ$ñrL   c                ó†   € \        W4      P                  \        P                  ! R V  4       !  4      P	                  V4      # )zEThe next page of candidates under at most PREFIX_BATCH_SIZE prefixes.c              3   óV   "  € T F  p\        \        P                  V4      x € K!  	  R # 5irN   )r   r   r¿   )rÚ   rÈ   s   & rI   rÜ   Ú8build_unenriched_candidates_statement.<locals>.<genexpr>Ž  s!   é € ÐVÉXÈÔ-¬l×.?Ñ.?À×CÐCËXùs   ‚'))rº  r  r  rµ  rž  )rÐ   r°  r±  rž  s   &&&&rI   Ú%build_unenriched_candidates_statementr¿  …  s3   € ô 	$ NÓAß	‰Œr�vŠvÑVÉXÓVÑWÓ	Xß	‰ˆu‹ðrL   c                ó’   € V ^8„  d   QhR\         \        R3,          R\        R\        R\        R,          R\
        \        ,          /# )rA   r7  .r°  rž  r±  NrC   )rï   r¸   rF   r\   rE   rq   rx   )rG   s   "rI   rJ   rJ   “  sM   € ÷ #ñ #Ü”˜3�Õð#äð#ô ð#ô ˜•*ð	#ô
 
Ô
Õñ#rL   c           
      ó>  a€ . pV  F  pVP                  \        V4      4       K  	  V'       g   . # \        4       ;_uu_ 4       p\        V4      \        8:  d/   \        VVVV4      pVP                  V4      P                  4       pMT\        V4      oVP                  \        W4      P                  R R7      4      p	\        \        V3R lV	 4       V4      4      pRRR4       X U
UUu. uF  w  r«p\        W«V4      NK  	  uppp
#   + '       g   i     L3; iu uppp
i )r.  r/  c              3   óV   <"  € T F  pS! V^,          4      '       g   K  Vx € K   	  R# 5i)rA   NrO   )rÚ   ÚrowÚis_unders   & €rI   rÜ   Ú2get_unenriched_assets_for_roots.<locals>.<genexpr>±  s   øé € ÐN©z¨¹XÀcÈ!Åf×=M§¢«zùs   ƒ)Ÿ
)N)r¾   rÉ   r<   r“   r   r¿  r1  rà   r   rº  r3  rq   r   rx   )r7  r°  rž  r±  rÐ   r·   r)  Ú	statementr5  r}  rz   r{   r|   rÄ  s   &&&&         @rI   Úget_unenriched_assets_for_rootsrÇ  “  s  ø€ ð €HÛˆØ�‰Ô2°4Ó8Ö9ñ ÷ Øˆ	ä	×	Ô	˜TÜˆx‹=Ô-Ô-Ü=ØØØØó	ˆIð —<‘< 	Ó*×.Ñ.Ó0‰Dô
 2°(Ó;ˆHØŸ™Ü+¨NÓI×[Ñ[ÐfiÐ[ÓjóˆJô œÔN©zÓNÐPUÓVÓWˆD÷# 
ñ* 15õá04Ñ,ˆJ 9ô 	˜*°Ö;Ù04óð ÷' 
×	üô&s   ÁBDÃ(DÄD	c                óz   € V ^8„  d   QhR\         R\         R\         R\        R\        R\        R,          R\        /# )	rA   r|   rz   r{   Úextract_metadataÚcompute_hashrî   NrC   )rE   rF   r?   )rG   s   "rI   rJ   rJ   ¹  sg   € ÷ ~Tñ ~Täð~Tô ð~Tô ð	~Tô
 ð~Tô ð~Tô ˜dÕ"ð~Tô 
ñ~TrL   c           	     óª  € Ve   V;P                   ^,          un          \        P                  ! VRR7      p\        T4      p	\        T4      p
RpRpT'       d#   \        TTT
R
7      pT'       d   TP                   pT P#                  \$        T4      pRpRpRpT;'       d    TRJ;'       d    TP&                  RJ pT'       d`    \)        T4      pTf@   Te   TP                  R4      '       d   \        R4       \*        P,                  ! RT4       R# Tw  pp\/        T4      pT P#                  \4        T4      pTe   Te   TP6                  T	8w  d*   T P9                  4        \*        P:                  ! RT4       R# TeU   \        T4      T	8w  g   TP<                  TP<                  8w  d*   T P9                  4        \*        P:                  ! RT4       R# T'       d]   T'       dU   TP?                  4       p\A        YR7      pT'       d   TPC                  T4       / TPD                  ;'       g    / CTCTn"        T'       d   Yýn        T'       d   TTn#        T PI                  4        T'       d   Tf   R# TRJ;'       g    TRJ;'       g    TRJ#   \         d     R# \         dƒ   p\        RT4       Teh   \        T\        4      '       d   T;P                  ^,          un        TP                  R4      '       d"   \        RR\        T4      \        T4      R	7        Rp?R# Rp?ii ; i  \0         dž   pTRJ pTe+   T;P2                  ^,          un        TP                  R4      pT'       d   \        R\        T4      R7       \        T\        4      '       d   \        RT4        Rp?EL‹\*        P,                  ! RTTRR7        Rp?EL«Rp?ii ; i)a¯  Enrich a single asset with metadata and/or hash.

Args:
    session: Database session (caller manages lifecycle)
    file_path: Absolute path to the file
    content_id: ID of the content to update
    record_id: ID of the record to update
    extract_metadata: If True, extract safetensors header and mime type
    compute_hash: If True, compute blake3 hash

Returns:
    Whether enrichment changed the B-schema record or content
NTrò   FÚenrichment_statzstat_failed:enrichrr  Úenrichrt  rv  Úhash_discarded_modifiedzscanner.hash_discarded_modifiedzEFile modified during hashing (snapshot unstable), discarding hash: %srT   zscanner.hash_failed©r   ÚhashingzFailed to hash %s: %s)Úexc_infozCContent %s mtime changed during enrichment, discarding stale resultzWContent %s changed between its metadata read and its hash read, discarding stale result)ro   )%rZ   r‚   rö   rù   r®   r´   r™   r±   rV   rQ   r   r   r   r0   r8   r7   ry  r
  r   r˜  r;   r²   r³   r   r  rT   r   rj   r­  Úinforx  Úto_user_metadatar5   rz  r¶  ro   r˜   )r¦   r|   rz   r{   rÉ  rÊ  rî   r~  rç   Úinitial_mtime_nsr‚  ro   rn   rü   ÚdigestÚstored_hashÚverified_statÚhash_requestedr‹  r¨   Úemit_failureÚrecordr¶  Údimss   &&&&&&&                 rI   Úenrich_assetrÜ  ¹  sY  € ð, ÒØ×Ò !Õ#ÕðÜ—’˜°DÔ9ˆô" $ FÓ+ÐÜ# IÓ.€IØ €IØ€HçÜ(ØØØ'ô
ˆ÷
 Ø ×-Ñ-ˆIà�k‰kœ,¨
Ó3€Gà€FØ"€KØ+/€MØ!×RÐR g°TÐ&9×RÐR¸g¿l¹lÈdÐ>R€Nßð	XÜ$ YÓ/ˆHØÒØÒ# x×'<Ñ'<Ð=V×'WÒ'WÜÐ:Ô;Ü—’Ø[Øôñ Ø$,Ñ!ˆF�MÜ(¨Ó0ˆKð �[‰[œ 	Ó*€FØ‚˜&š.¨G×,<Ñ,<Ð@PÔ,PØ×ÑÔÜ�ŠØQØô	
ñ ð Ò Ü�]Ó#Ð'7Ô7Ø× Ñ  F§N¡NÔ2à×ÑÔÜ�Šð&àô	
ñ
 çŸHØ"×3Ñ3Ó5ˆÜ% iÔEˆßØ×"Ñ" 4Ô(Ø!V V×%;Ñ%;×%AÐ%A¸rÐ!VÀoÐ!VˆÔçØ"ŒßØ$ˆÔà‡N�NÔç˜+Ò-ÙØ˜dÐ"×SÐS h°dÐ&:×SÐS¸iÈtÐ>SÐSøôI ô ÚÜô ÜÐ)¨1Ô-ØÒÜ˜!œ_×-Ò-Ø×*Ò*¨aÕ/Õ*Ø×$Ñ$Ð%9×:Ò:ÜØ)Ø!Ü)¨!›}Ü)¨!›}õ	õ ûðûô^ ô 
	XØ# tÐ+ˆLØÒ#Ø×$Ò$¨Õ)Õ$Ø'×4Ñ4°]ÓC�ßÜÐ*´zÀ#³ÕGÜ˜#œw×'Ò'Ü 	¨3×/Ò/ä—’Ð 7¸ÀCÐRV×WÓWûð
	XúsZ   ŸJ Ã)L* Ã."L* ÄL* ÊL'ÊL'Ê$L'Ê%AL"Ë;!L"Ì"L'Ì*OÌ59OÍ/8OÎ-OÏOc                óî   € V ^8„  d   QhR\         \        ,          R\        R\        R\        . \        3,          R,          R\        R,          R\
        \        \         \        ,          \        3,          /# )rA   r5  rÉ  rÊ  Úinterrupt_checkNrî   rC   )rq   rx   rF   r   r?   rï   r\   rE   )rG   s   "rI   rJ   rJ   :  sm   € ÷ 8*ñ 8*Ü
Ô Õ
!ð8*äð8*ô ð8*ô ˜b¤$˜hÕ'¨$Õ.ð	8*ô
 ˜dÕ"ð8*ô Œ3””S•	œ3ÐÕñ8*rL   c                óä  € ^ p. p^ p\        4       ;_uu_ 4       pV  F~  p	Ve   V! 4       '       d    MlV^,          p \        VV	P                  V	P                  V	P                  VVVR7      p
V
'       d   V^,          pKc  VP                  V	P                  4       K€  	  RRR4       WVV3#   \         d¨   pTe   T;P                  ^,          un        Te   TP                  R4      '       d   \        R\        T4      R7       \        P                  ! RT	P                  T4       TP                  4        TP                  T	P                  4        Rp?EK;  Rp?ii ; i  + '       g   i     LÉ; i)aq  Enrich a batch of assets.

Uses a single DB session for the entire batch, committing after each
individual asset to avoid long-held transactions while eliminating
per-asset session creation overhead.

Args:
    rows: List of UnenrichedReferenceRow from get_unenriched_assets_for_roots
    extract_metadata: If True, extract metadata for each asset
    compute_hash: If True, compute hash for each asset
    interrupt_check: Optional non-blocking callable that returns True if
        the operation should be interrupted (e.g. paused or cancelled)

Returns:
    Tuple of (enriched_count, failed_reference_ids, consumed_count)
N)r|   rz   r{   rÉ  rÊ  rî   rU   zscanner.enrich_failedrÏ  zFailed to enrich %s: %s)r<   rÜ  r|   rz   r{   rž   r  rU   rQ   r   r   r²   r³   r­  )r5  rÉ  rÊ  rÞ  rî   ÚenrichedÚ
failed_idsÚconsumedr)  rÃ  Úupdatedr¨   s   &&&&&       rI   Úenrich_assets_batchrä  :  s.  € ð. €HØ€JØ€Hä	×	Ô	˜TÛˆCØÒ*©×/@Ò/@ÙØ˜�MˆHð1Ü&ØØ!Ÿm™mØ"Ÿ~™~Ø!Ÿm™mØ%5Ø!-Ø%ô�÷ Ø •M’Hà×%Ñ% c§m¡mÖ4ñ% ÷ 
ð:  Ð)Ð)øô ô 1ØÒ'Ø×*Ò*¨aÕ/Õ*ØÒ# x×'<Ñ'<¸_×'MÒ'MÜÐ0¼ZÈ»_ÕMÜ—’Ð 9¸3¿=¹=È#ÔNØ—‘”Ø×!Ñ! #§-¡-×0Ó0ûð1ú÷) 
×	úsM   ™E°E¼AB*Á=EÁ?B*ÂEÂ*E	Â57E	Ã-A#E	ÅEÅE	ÅEÅE/	)r   r!   r$   rº   rN   )NNN)éè  )rå  N)TFN)TFNN)‹r…   Úenumr²   r‚   r›   r–   Údataclassesr   Ú	itertoolsr   Úpathlibr   Útypingr   r   r   r   r	   rÁ   Ú
sqlalchemyr  Úsqlalchemy.excr
   r   Úsqlalchemy.ormr   Ú
app.assetsr   Úapp.assets.event_logr   r   r   Úapp.assets.database.queriesr   r   r   r   Úapp.assets.database.modelsr   r   Úapp.assets.helpersr   r   r   r   r   r   r   Úapp.assets.lifecycler   Úapp.assets.scanner_changesr   r    r!   r"   r#   r$   r%   r&   Úapp.assets.scanner_admissionr'   r(   r)   r*   r+   r,   Úapp.assets.services.file_utilsr-   r.   r/   r0   r1   r2   r3   Úapp.assets.services.gilr4   Ú"app.assets.services.media_metadatar5   Ú$app.assets.services.metadata_extractr6   r7   Úapp.assets.services.path_utilsr8   r9   r:   Ú!app.assets.services.snapshot_hashr;   Úapp.database.dbr<   r=   Ú__all__r¸   r?   rf   rx   r   rF   r�   r‰   r”   r¡   r¢   r•   r�   rª   r´   rÉ   rÑ   rÍ   rì   r   r  r  r  r!  r+  r(  r9  r<  rH  rT  rO  ÚEnumrM  rL  ri  rl  rƒ  r…  r‰  r’  r§  r›  r®  rº  r¿  rÇ  rÜ  rä  rO   rL   rI   Ú<module>rÿ     sL  ðñó Û Û 	Û Û Ý !Ý Ý ß EÕ Eã Û ß ;Ý "Ý ß =Ñ =÷ó ÷ ;÷÷ ñ õ 9÷	÷ 	ó 	÷÷ ÷÷ ñ õ .Ý Eß Y÷ñ õ
 <ß @ò€ð Ð.Õ/€ô	2�Hô 	2ô�Iô ñ �$˜dÔ#÷ð ó $ðô'˜Jô 'ð �b˜$�hÕ€
õð Ð ØÐ ØÐ ØÐ ØÐ õ!YõHSõ
õeõõ÷>##õL5õ:ð$ &*Ø)÷ð: &*Ø)÷
ð$ 4?÷õ:	Kð &*Ø)÷õ0
'õ#÷LõB	ô�T—Y‘Yô õNð6 &*Ø)÷	/õ.>ð (,Ø%)Ø)÷Z$ðz ÷ð ó ðô0�zô 0÷÷<W õtW÷$õB*÷.÷#÷L~T÷B8*ñ 8*rL   