Ripple verbosity flags through the server

This commit is contained in:
Lucien Greathouse
2017-12-01 00:17:29 -08:00
parent 7f3aaf4680
commit 63b21b90ff
3 changed files with 22 additions and 4 deletions

View File

@@ -128,7 +128,7 @@ fn main() {
}
let vfs = {
let mut vfs = Vfs::new();
let mut vfs = Vfs::new(config.clone());
for (name, project_partition) in &project.partitions {
let path = {
@@ -158,9 +158,10 @@ fn main() {
{
let vfs = vfs.clone();
let config = config.clone();
thread::spawn(move || {
VfsWatcher::new(vfs).start();
VfsWatcher::new(config, vfs).start();
});
}

View File

@@ -5,6 +5,8 @@ use std::io::Read;
use std::path::{Path, PathBuf};
use std::time::Instant;
use core::Config;
/// Represents a virtual layer over multiple parts of the filesystem.
///
/// Paths in this system are represented as slices of strings, and are always
@@ -21,6 +23,8 @@ pub struct Vfs {
/// A chronologically-sorted list of routes that changed since the Vfs was
/// created, along with a timestamp denoting when.
pub change_history: Vec<VfsChange>,
config: Config,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -38,11 +42,12 @@ pub enum VfsItem {
}
impl Vfs {
pub fn new() -> Vfs {
pub fn new(config: Config) -> Vfs {
Vfs {
partitions: HashMap::new(),
start_time: Instant::now(),
change_history: Vec::new(),
config,
}
}
@@ -140,6 +145,10 @@ impl Vfs {
}
pub fn add_change(&mut self, timestamp: f64, route: Vec<String>) {
if self.config.verbose {
println!("Added change {:?}", route);
}
self.change_history.push(VfsChange {
timestamp,
route,

View File

@@ -6,17 +6,20 @@ use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use vfs::Vfs;
use pathext::path_to_route;
use core::Config;
pub struct VfsWatcher {
vfs: Arc<Mutex<Vfs>>,
watchers: Vec<RecommendedWatcher>,
config: Config,
}
impl VfsWatcher {
pub fn new(vfs: Arc<Mutex<Vfs>>) -> VfsWatcher {
pub fn new(config: Config, vfs: Arc<Mutex<Vfs>>) -> VfsWatcher {
VfsWatcher {
vfs,
watchers: Vec::new(),
config,
}
}
@@ -40,6 +43,7 @@ impl VfsWatcher {
{
let vfs = self.vfs.clone();
let config = self.config.clone();
thread::spawn(move || {
loop {
@@ -47,6 +51,10 @@ impl VfsWatcher {
let mut vfs = vfs.lock().unwrap();
let current_time = vfs.current_time();
if config.verbose {
println!("FS event {:?}", event);
}
match event {
DebouncedEvent::Write(ref change_path) |
DebouncedEvent::Create(ref change_path) |