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

Tolerate errors when attempting to fetch metadata for some CreateKinds #3393

Merged
merged 7 commits into from
Aug 8, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/agent/onefuzz/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

use anyhow::{format_err, Context, Result};
use anyhow::{format_err, Result};
use notify::{
event::{CreateKind, ModifyKind, RenameMode},
Event, EventKind, Watcher,
Expand Down Expand Up @@ -132,17 +132,11 @@ impl DirectoryMonitor {
}
}
CreateKind::Any | CreateKind::Other => {
if self.report_directories {
Porges marked this conversation as resolved.
Show resolved Hide resolved
return Ok(Some(path));
}

// check if it is a file
let metadata = fs::metadata(&path)
.await
.context("checking metadata for file")?;

if metadata.is_file() {
return Ok(Some(path));
if let Ok(metadata) = fs::metadata(&path).await {
// check if it is a file or a folder
if metadata.is_file() || self.report_directories {
return Ok(Some(path));
}
DrChat marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
Loading