@@ -71,29 +71,7 @@ impl FileWatcher {
7171 fn scan_files ( & self , states : & mut HashMap < PathBuf , SystemTime > ) -> anyhow:: Result < ( ) > {
7272 let mut dirs = vec ! [ self . root. clone( ) ] ;
7373 while let Some ( dir) = dirs. pop ( ) {
74- if dir. is_dir ( ) {
75- if let Ok ( entries) = std:: fs:: read_dir ( dir) {
76- for entry in entries. flatten ( ) {
77- let path = entry. path ( ) ;
78- if path. is_dir ( ) {
79- // Don't watch build or cache directories to prevent infinite loops
80- let name = path. file_name ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
81- if name != "build" && name != ".git" && name != "target" {
82- dirs. push ( path) ;
83- }
84- } else {
85- let ext = path. extension ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
86- if ext == "txs" || ext == "ts" {
87- if let Ok ( metadata) = entry. metadata ( ) {
88- if let Ok ( modified) = metadata. modified ( ) {
89- states. insert ( path, modified) ;
90- }
91- }
92- }
93- }
94- }
95- }
96- } else {
74+ if !dir. is_dir ( ) {
9775 // Root is a single file
9876 let ext = self . root . extension ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
9977 if ext == "txs" || ext == "ts" {
@@ -103,6 +81,32 @@ impl FileWatcher {
10381 }
10482 }
10583 }
84+ continue ;
85+ }
86+
87+ if let Ok ( entries) = std:: fs:: read_dir ( dir) {
88+ for entry in entries. flatten ( ) {
89+ let path = entry. path ( ) ;
90+ if path. is_dir ( ) {
91+ // Don't watch build or cache directories to prevent infinite loops
92+ let name = path. file_name ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
93+ if name != "build" && name != ".git" && name != "target" {
94+ dirs. push ( path) ;
95+ }
96+ continue ;
97+ }
98+
99+ let ext = path. extension ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
100+ if ext != "txs" && ext != "ts" {
101+ continue ;
102+ }
103+
104+ if let Ok ( metadata) = entry. metadata ( ) {
105+ if let Ok ( modified) = metadata. modified ( ) {
106+ states. insert ( path, modified) ;
107+ }
108+ }
109+ }
106110 }
107111 }
108112 Ok ( ( ) )
0 commit comments