Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 9562975

Browse files
authored
Merge branch 'main' into windows-rs
2 parents bb25e26 + 3851ab0 commit 9562975

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/agent/onefuzz/src/monitor.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use std::path::{Path, PathBuf};
55

6-
use anyhow::{format_err, Context, Result};
6+
use anyhow::{format_err, Result};
77
use 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
}

0 commit comments

Comments
 (0)