diff --git a/src/filecache/mod.rs b/src/filecache/mod.rs index fe91d95..d0f7f25 100755 --- a/src/filecache/mod.rs +++ b/src/filecache/mod.rs @@ -1,5 +1,3 @@ -#![allow(dead_code)] - use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; @@ -16,13 +14,6 @@ use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher}; type CacheGuard = Arc>; -#[derive(Debug)] -pub enum FileEntryError { - NeedsUpdate, - EmptyFile, - FileOpenError, -} - #[derive(Debug)] pub struct FileEntry { path: CacheGuard, @@ -57,7 +48,6 @@ impl FileEntry { Arc::new(RwLock::new(String::from(&*path))) } - // HACK: this whole function has been hacked up trying to fix dead locks. fn do_hash(&mut self) { let path_ptr = self.path.clone(); let path_lock = path_ptr.read().unwrap(); @@ -75,7 +65,6 @@ impl FileEntry { }; let mut hasher = blake3::Hasher::new(); - // HACK: this feels bad... hasher.update_rayon( &temp_content .bytes() @@ -98,36 +87,6 @@ impl FileEntry { *self.hash.write().unwrap() = Some(hasher.finalize()); } - /* - - loop { - let has_content = ptr.read().unwrap().is_some(); - if has_content { - let mut hasher = blake3::Hasher::new(); - hasher.update_rayon(content.get_ref()); - - - let hash_ptr = self.hash.clone(); - let hash_ptr = hash_ptr.write().unwrap(); - let hash_ptr = Some(hasher.finalize()); - - break; - } else { - - let content_lock = self.content.clone(); - let mut content = content_lock.write().unwrap(); - - if content.is_none() { - let path_lock = self.path.clone(); - let file = std::fs::File::open(path_lock.read().unwrap().as_path()); - let file = file.unwrap_or_else(|_| panic!("issue opening file for {:#?}", &self.path)); - - - continue; - } - } - - */ } } @@ -142,7 +101,7 @@ pub struct FileCache { cache: CacheGuard>>, cache_dir: std::path::PathBuf, notify_watcher: RecommendedWatcher, - notify_thread: std::thread::JoinHandle<()>, + _notify_thread: std::thread::JoinHandle<()>, } impl FileCache { @@ -171,7 +130,7 @@ impl FileCache { cache: Arc::new(RwLock::new(HashMap::new())), cache_dir: cache_dir.to_path_buf(), notify_watcher: notify::Watcher::new(tx, Duration::from_secs(1)).unwrap(), - notify_thread: thread::Builder::new() + _notify_thread: thread::Builder::new() .name("notify-thread".to_string()) .spawn(move || FileCache::notify_loop(rx)) .unwrap(), @@ -222,10 +181,9 @@ impl FileCache { } fn notify_loop(rx: Receiver) { - let this_thread = std::thread::current(); - log::info!("notify loop starting on thread-{:?}", &this_thread); + log::info!("notify loop starting on thread-{:?}", std::thread::current()); - let thread_name: String = match &this_thread.name() { + let thread_name: String = match std::thread::current().name() { Some(s) => s.to_string(), None => "notify-thread".to_string(), }; diff --git a/src/main.rs b/src/main.rs index 0003e9a..fabc8e2 100755 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,6 @@ extern crate notify; /* general utility crates */ //extern crate chrono; -extern crate lazy_static; extern crate regex; mod filecache;