Skip to content

Commit

Permalink
fix: error on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kabouzeid committed Mar 28, 2023
1 parent 1f1a5ac commit ff516ca
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use crossbeam::{
channel::{unbounded, Receiver, Sender},
channel::{unbounded, Receiver, RecvError, SendError, Sender},
select,
};
use notify::{event::ModifyKind, RecursiveMode, Watcher};
Expand Down Expand Up @@ -49,7 +49,7 @@ impl FileWatcher {
}
}

fn run(&mut self) {
fn run(&mut self) -> Result<(), RecvError> {
let (watch_sender, watch_receiver) = unbounded();
let mut watcher = notify::recommended_watcher(move |res: notify::Result<notify::Event>| {
let event = res.unwrap();
Expand All @@ -67,7 +67,7 @@ impl FileWatcher {
loop {
select! {
recv(self.receiver) -> msg => {
match msg.unwrap() {
match msg? {
FileWatcherMessage::FilePath(file_path) => {
(_content_sender, _content_receiver) = unbounded();
(_watch_sender, _watch_receiver) = unbounded::<()>();
Expand Down Expand Up @@ -129,7 +129,7 @@ impl FileReader {
}
}

fn update(&self) -> Result<(), crossbeam::channel::SendError<Option<String>>> {
fn update(&self) -> Result<(), SendError<Option<String>>> {
let s = self.file_path.as_ref().and_then(|file_path| {
// TODO: partial read only
fs::read_to_string(file_path).ok()
Expand Down

0 comments on commit ff516ca

Please sign in to comment.