mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 15:16:07 +00:00
Ripple verbosity flags through the server
This commit is contained in:
@@ -128,7 +128,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let vfs = {
|
let vfs = {
|
||||||
let mut vfs = Vfs::new();
|
let mut vfs = Vfs::new(config.clone());
|
||||||
|
|
||||||
for (name, project_partition) in &project.partitions {
|
for (name, project_partition) in &project.partitions {
|
||||||
let path = {
|
let path = {
|
||||||
@@ -158,9 +158,10 @@ fn main() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let vfs = vfs.clone();
|
let vfs = vfs.clone();
|
||||||
|
let config = config.clone();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
VfsWatcher::new(vfs).start();
|
VfsWatcher::new(config, vfs).start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/vfs.rs
11
src/vfs.rs
@@ -5,6 +5,8 @@ use std::io::Read;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use core::Config;
|
||||||
|
|
||||||
/// Represents a virtual layer over multiple parts of the filesystem.
|
/// Represents a virtual layer over multiple parts of the filesystem.
|
||||||
///
|
///
|
||||||
/// Paths in this system are represented as slices of strings, and are always
|
/// 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
|
/// A chronologically-sorted list of routes that changed since the Vfs was
|
||||||
/// created, along with a timestamp denoting when.
|
/// created, along with a timestamp denoting when.
|
||||||
pub change_history: Vec<VfsChange>,
|
pub change_history: Vec<VfsChange>,
|
||||||
|
|
||||||
|
config: Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@@ -38,11 +42,12 @@ pub enum VfsItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Vfs {
|
impl Vfs {
|
||||||
pub fn new() -> Vfs {
|
pub fn new(config: Config) -> Vfs {
|
||||||
Vfs {
|
Vfs {
|
||||||
partitions: HashMap::new(),
|
partitions: HashMap::new(),
|
||||||
start_time: Instant::now(),
|
start_time: Instant::now(),
|
||||||
change_history: Vec::new(),
|
change_history: Vec::new(),
|
||||||
|
config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,6 +145,10 @@ impl Vfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_change(&mut self, timestamp: f64, route: Vec<String>) {
|
pub fn add_change(&mut self, timestamp: f64, route: Vec<String>) {
|
||||||
|
if self.config.verbose {
|
||||||
|
println!("Added change {:?}", route);
|
||||||
|
}
|
||||||
|
|
||||||
self.change_history.push(VfsChange {
|
self.change_history.push(VfsChange {
|
||||||
timestamp,
|
timestamp,
|
||||||
route,
|
route,
|
||||||
|
|||||||
@@ -6,17 +6,20 @@ use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
|
|||||||
|
|
||||||
use vfs::Vfs;
|
use vfs::Vfs;
|
||||||
use pathext::path_to_route;
|
use pathext::path_to_route;
|
||||||
|
use core::Config;
|
||||||
|
|
||||||
pub struct VfsWatcher {
|
pub struct VfsWatcher {
|
||||||
vfs: Arc<Mutex<Vfs>>,
|
vfs: Arc<Mutex<Vfs>>,
|
||||||
watchers: Vec<RecommendedWatcher>,
|
watchers: Vec<RecommendedWatcher>,
|
||||||
|
config: Config,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VfsWatcher {
|
impl VfsWatcher {
|
||||||
pub fn new(vfs: Arc<Mutex<Vfs>>) -> VfsWatcher {
|
pub fn new(config: Config, vfs: Arc<Mutex<Vfs>>) -> VfsWatcher {
|
||||||
VfsWatcher {
|
VfsWatcher {
|
||||||
vfs,
|
vfs,
|
||||||
watchers: Vec::new(),
|
watchers: Vec::new(),
|
||||||
|
config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,6 +43,7 @@ impl VfsWatcher {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let vfs = self.vfs.clone();
|
let vfs = self.vfs.clone();
|
||||||
|
let config = self.config.clone();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
@@ -47,6 +51,10 @@ impl VfsWatcher {
|
|||||||
let mut vfs = vfs.lock().unwrap();
|
let mut vfs = vfs.lock().unwrap();
|
||||||
let current_time = vfs.current_time();
|
let current_time = vfs.current_time();
|
||||||
|
|
||||||
|
if config.verbose {
|
||||||
|
println!("FS event {:?}", event);
|
||||||
|
}
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
DebouncedEvent::Write(ref change_path) |
|
DebouncedEvent::Write(ref change_path) |
|
||||||
DebouncedEvent::Create(ref change_path) |
|
DebouncedEvent::Create(ref change_path) |
|
||||||
|
|||||||
Reference in New Issue
Block a user