File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 33
44use std:: path:: { Path , PathBuf } ;
55
6- use anyhow:: { format_err, Context , Result } ;
6+ use anyhow:: { format_err, Result } ;
77use notify:: {
88 event:: { CreateKind , ModifyKind , RenameMode } ,
99 Event , EventKind , Watcher ,
@@ -132,17 +132,21 @@ impl DirectoryMonitor {
132132 }
133133 }
134134 CreateKind :: Any | CreateKind :: Other => {
135+ // Short-circuit and report this path if we're reporting everything.
135136 if self . report_directories {
136137 return Ok ( Some ( path) ) ;
137138 }
138139
139- // check if it is a file
140- let metadata = fs:: metadata ( & path)
141- . await
142- . context ( "checking metadata for file" ) ?;
143-
144- if metadata. is_file ( ) {
145- return Ok ( Some ( path) ) ;
140+ match fs:: metadata ( & path) . await {
141+ Ok ( metadata) => {
142+ // We're only reporting files, so make sure this is a file first.
143+ if metadata. is_file ( ) {
144+ return Ok ( Some ( path) ) ;
145+ }
146+ }
147+ Err ( e) => {
148+ warn ! ( "failed to get metadata for {}: {:?}" , path. display( ) , e) ;
149+ }
146150 }
147151 }
148152 }
You can’t perform that action at this time.
0 commit comments