mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 07:06:12 +00:00
Trim up dead/dying code
This commit is contained in:
@@ -78,15 +78,7 @@ impl Imfs {
|
|||||||
debug_assert!(path.is_absolute());
|
debug_assert!(path.is_absolute());
|
||||||
debug_assert!(self.is_within_roots(path));
|
debug_assert!(self.is_within_roots(path));
|
||||||
|
|
||||||
if let Some(parent_path) = path.parent() {
|
self.read_from_disk(path)
|
||||||
if self.is_within_roots(parent_path) && self.get(parent_path).is_none() {
|
|
||||||
self.path_created(parent_path)?;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.read_from_disk(path)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path_removed(&mut self, path: &Path) -> io::Result<()> {
|
pub fn path_removed(&mut self, path: &Path) -> io::Result<()> {
|
||||||
@@ -192,33 +184,16 @@ impl Imfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_within_roots(&self, path: &Path) -> bool {
|
fn is_within_roots(&self, path: &Path) -> bool {
|
||||||
let kind = self.classify_path(path);
|
|
||||||
|
|
||||||
kind == PathKind::Root || kind == PathKind::InRoot
|
|
||||||
}
|
|
||||||
|
|
||||||
fn classify_path(&self, path: &Path) -> PathKind {
|
|
||||||
for root_path in &self.roots {
|
for root_path in &self.roots {
|
||||||
if root_path == path {
|
|
||||||
return PathKind::Root;
|
|
||||||
}
|
|
||||||
|
|
||||||
if path.starts_with(root_path) {
|
if path.starts_with(root_path) {
|
||||||
return PathKind::InRoot;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PathKind::NotInRoot
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
||||||
enum PathKind {
|
|
||||||
Root,
|
|
||||||
InRoot,
|
|
||||||
NotInRoot,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct ImfsFile {
|
pub struct ImfsFile {
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use librojo::{
|
|||||||
imfs::{Imfs, ImfsItem, ImfsFile, ImfsDirectory},
|
imfs::{Imfs, ImfsItem, ImfsFile, ImfsDirectory},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
enum FsEvent {
|
enum FsEvent {
|
||||||
Created(PathBuf),
|
Created(PathBuf),
|
||||||
Updated(PathBuf),
|
Updated(PathBuf),
|
||||||
@@ -125,7 +126,7 @@ fn base_tree() -> io::Result<(TempDir, Imfs, ExpectedImfs, TestResources)> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn initial_read() -> io::Result<()> {
|
fn initial_read() -> io::Result<()> {
|
||||||
let (_, imfs, expected_imfs, _) = base_tree()?;
|
let (_root, imfs, expected_imfs, _resources) = base_tree()?;
|
||||||
|
|
||||||
check_expected(&imfs, &expected_imfs);
|
check_expected(&imfs, &expected_imfs);
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ fn adding_files() -> io::Result<()> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn adding_folder() -> io::Result<()> {
|
fn adding_folder() -> io::Result<()> {
|
||||||
let (root, mut imfs, mut expected_imfs, resources) = base_tree()?;
|
let (root, imfs, mut expected_imfs, _resources) = base_tree()?;
|
||||||
|
|
||||||
check_expected(&imfs, &expected_imfs);
|
check_expected(&imfs, &expected_imfs);
|
||||||
|
|
||||||
@@ -236,7 +237,7 @@ fn adding_folder() -> io::Result<()> {
|
|||||||
for events in &possible_event_sequences {
|
for events in &possible_event_sequences {
|
||||||
let mut imfs = imfs.clone();
|
let mut imfs = imfs.clone();
|
||||||
|
|
||||||
send_events(&mut imfs, events);
|
send_events(&mut imfs, events)?;
|
||||||
check_expected(&imfs, &expected_imfs);
|
check_expected(&imfs, &expected_imfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +270,7 @@ fn removing_file() -> io::Result<()> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn removing_folder() -> io::Result<()> {
|
fn removing_folder() -> io::Result<()> {
|
||||||
let (root, mut imfs, mut expected_imfs, resources) = base_tree()?;
|
let (root, imfs, mut expected_imfs, resources) = base_tree()?;
|
||||||
|
|
||||||
check_expected(&imfs, &expected_imfs);
|
check_expected(&imfs, &expected_imfs);
|
||||||
|
|
||||||
@@ -298,7 +299,7 @@ fn removing_folder() -> io::Result<()> {
|
|||||||
for events in &possible_event_sequences {
|
for events in &possible_event_sequences {
|
||||||
let mut imfs = imfs.clone();
|
let mut imfs = imfs.clone();
|
||||||
|
|
||||||
send_events(&mut imfs, events);
|
send_events(&mut imfs, events)?;
|
||||||
check_expected(&imfs, &expected_imfs);
|
check_expected(&imfs, &expected_imfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user