Trim up dead/dying code

This commit is contained in:
Lucien Greathouse
2018-12-14 21:42:38 -08:00
parent 893587040d
commit f125814847
2 changed files with 9 additions and 33 deletions

View File

@@ -78,15 +78,7 @@ impl Imfs {
debug_assert!(path.is_absolute());
debug_assert!(self.is_within_roots(path));
if let Some(parent_path) = path.parent() {
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(())
self.read_from_disk(path)
}
pub fn path_removed(&mut self, path: &Path) -> io::Result<()> {
@@ -192,33 +184,16 @@ impl Imfs {
}
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 {
if root_path == path {
return PathKind::Root;
}
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)]
pub struct ImfsFile {
pub path: PathBuf,

View File

@@ -11,6 +11,7 @@ use librojo::{
imfs::{Imfs, ImfsItem, ImfsFile, ImfsDirectory},
};
#[allow(unused)]
enum FsEvent {
Created(PathBuf),
Updated(PathBuf),
@@ -125,7 +126,7 @@ fn base_tree() -> io::Result<(TempDir, Imfs, ExpectedImfs, TestResources)> {
#[test]
fn initial_read() -> io::Result<()> {
let (_, imfs, expected_imfs, _) = base_tree()?;
let (_root, imfs, expected_imfs, _resources) = base_tree()?;
check_expected(&imfs, &expected_imfs);
@@ -178,7 +179,7 @@ fn adding_files() -> io::Result<()> {
#[test]
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);
@@ -236,7 +237,7 @@ fn adding_folder() -> io::Result<()> {
for events in &possible_event_sequences {
let mut imfs = imfs.clone();
send_events(&mut imfs, events);
send_events(&mut imfs, events)?;
check_expected(&imfs, &expected_imfs);
}
@@ -269,7 +270,7 @@ fn removing_file() -> io::Result<()> {
#[test]
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);
@@ -298,7 +299,7 @@ fn removing_folder() -> io::Result<()> {
for events in &possible_event_sequences {
let mut imfs = imfs.clone();
send_events(&mut imfs, events);
send_events(&mut imfs, events)?;
check_expected(&imfs, &expected_imfs);
}