Skip to content

Commit

Permalink
Fix clippy warnings / errors in filewatching code (#5891)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Soltis authored Sep 6, 2023
1 parent d652ef9 commit c7eb255
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/turborepo-filewatch/src/cookie_jar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async fn watch_cookies(
.expect("Non-absolute path from filewatching");
if root.relation_to_path(abs_path) == PathRelation::Parent {
if let Some(responder) = watches.cookies.remove(&path) {
if let Err(_) = responder.send(Ok(())) {
if responder.send(Ok(())).is_err() {
// Note that cookie waiters will time out if they don't get a
// response, so we don't necessarily
// need to panic here, although we could decide to do that in the
Expand All @@ -151,7 +151,7 @@ async fn watch_cookies(
let resp = if is_closing { WatchError::Closed } else { e };
let mut watches = watches.lock().expect("mutex poisoned");
for (_, sender) in watches.cookies.drain() {
if let Err(_) = sender.send(Err(resp.clone())) {
if sender.send(Err(resp.clone())).is_err() {
// Note that cookie waiters will time out if they don't get a response, so
// we don't necessarily need to panic here, although
// we could decide to do that in the future.
Expand Down
3 changes: 3 additions & 0 deletions crates/turborepo-filewatch/src/fsevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
//! [ref]: https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/

#![allow(non_upper_case_globals, dead_code)]
// bitflags! with a 0 value defined triggers this clippy error,
// but we want to be able to define a value for fs::kFSEventStreamEventFlagNone
#![allow(clippy::bad_bit_mask)]

use std::{
collections::HashMap,
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-filewatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl FileSystemWatcher {
let watcher = run_watcher(&watch_root, send_file_events).unwrap();
let (exit_ch, exit_signal) = tokio::sync::oneshot::channel();
// Ensure we are ready to receive new events, not events for existing state
futures::executor::block_on(wait_for_cookie(&root, &mut recv_file_events))?;
futures::executor::block_on(wait_for_cookie(root, &mut recv_file_events))?;
tokio::task::spawn(watch_events(
watcher,
watch_root,
Expand Down Expand Up @@ -233,7 +233,7 @@ fn watch_parents(root: &AbsoluteSystemPath, watcher: &mut Backend) -> Result<(),

#[cfg(not(feature = "manual_recursive_watch"))]
fn watch_recursively(root: &AbsoluteSystemPath, watcher: &mut Backend) -> Result<(), WatchError> {
watcher.watch(&root.as_std_path(), RecursiveMode::Recursive)?;
watcher.watch(root.as_std_path(), RecursiveMode::Recursive)?;
Ok(())
}

Expand Down

0 comments on commit c7eb255

Please sign in to comment.