forked from rojo-rbx/rojo
Insulate VFS internals a little bit
This commit is contained in:
@@ -79,7 +79,7 @@ pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vfs.partitions.insert(name.clone(), path);
|
vfs.insert_partition(name, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arc::new(Mutex::new(vfs))
|
Arc::new(Mutex::new(vfs))
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ pub struct VfsSession {
|
|||||||
/// Contains all of the partitions mounted by the Vfs.
|
/// Contains all of the partitions mounted by the Vfs.
|
||||||
///
|
///
|
||||||
/// These must be absolute paths!
|
/// These must be absolute paths!
|
||||||
pub partitions: HashMap<String, PathBuf>,
|
partitions: HashMap<String, PathBuf>,
|
||||||
|
|
||||||
/// When the Vfs was initialized; used for change tracking.
|
|
||||||
pub start_time: Instant,
|
|
||||||
|
|
||||||
/// 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>,
|
change_history: Vec<VfsChange>,
|
||||||
|
|
||||||
|
/// When the Vfs was initialized; used for change tracking.
|
||||||
|
start_time: Instant,
|
||||||
|
|
||||||
plugin_chain: &'static PluginChain,
|
plugin_chain: &'static PluginChain,
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,18 @@ impl VfsSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_partitions(&self) -> &HashMap<String, PathBuf> {
|
||||||
|
&self.partitions
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert_partition<P: Into<PathBuf>>(&mut self, name: &str, path: P) {
|
||||||
|
let path = path.into();
|
||||||
|
|
||||||
|
assert!(path.is_absolute());
|
||||||
|
|
||||||
|
self.partitions.insert(name.to_string(), path.into());
|
||||||
|
}
|
||||||
|
|
||||||
fn route_to_path(&self, route: &[String]) -> Option<PathBuf> {
|
fn route_to_path(&self, route: &[String]) -> Option<PathBuf> {
|
||||||
let (partition_name, rest) = match route.split_first() {
|
let (partition_name, rest) = match route.split_first() {
|
||||||
Some((first, rest)) => (first, rest),
|
Some((first, rest)) => (first, rest),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl VfsWatcher {
|
|||||||
pub fn start(mut self) {
|
pub fn start(mut self) {
|
||||||
let outer_vfs = self.vfs.lock().unwrap();
|
let outer_vfs = self.vfs.lock().unwrap();
|
||||||
|
|
||||||
for (partition_name, root_path) in &outer_vfs.partitions {
|
for (partition_name, root_path) in outer_vfs.get_partitions() {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
let partition_name = partition_name.clone();
|
let partition_name = partition_name.clone();
|
||||||
let root_path = root_path.clone();
|
let root_path = root_path.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user