Skip to content
Open
Changes from all 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
14 changes: 14 additions & 0 deletions src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ impl FileWatcher {
// File was created or modified
let content = match std::fs::read_to_string(path) {
Ok(c) => c,
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
// File was deleted between check and read (TOCTOU)
if let Some(entry) = db.get_file_by_path(path)? {
db.delete_file(entry.id)?;
println!(
" {} {} {} {}",
style("[-]").red(),
style("removed").red(),
style(filename).dim(),
style("(race condition handled)").dim()
);
}
continue;
}
Err(_) => continue, // Skip binary or unreadable files
};

Expand Down
Loading