imfs: Correctly mark children_enumerated when calling get_children

This commit is contained in:
Lucien Greathouse
2019-09-24 17:57:06 -07:00
parent 061a096600
commit 0f2e2406e8

View File

@@ -221,13 +221,14 @@ impl<F: ImfsFetcher> Imfs<F> {
self.read_if_not_exists(path)?; self.read_if_not_exists(path)?;
match self.inner.get(path).unwrap() { match self.inner.get_mut(path).unwrap() {
ImfsItem::Directory(dir) => { ImfsItem::Directory(dir) => {
self.fetcher.watch(path); self.fetcher.watch(path);
if dir.children_enumerated { let enumerated = dir.children_enumerated;
return self
.inner if enumerated {
self.inner
.children(path) .children(path)
.unwrap() // TODO: Handle None here, which means the PathMap entry did not exist. .unwrap() // TODO: Handle None here, which means the PathMap entry did not exist.
.into_iter() .into_iter()
@@ -235,8 +236,9 @@ impl<F: ImfsFetcher> Imfs<F> {
.collect::<Vec<PathBuf>>() // Collect all PathBufs, since self.get needs to borrow self mutably. .collect::<Vec<PathBuf>>() // Collect all PathBufs, since self.get needs to borrow self mutably.
.into_iter() .into_iter()
.map(|path| self.get(path)) .map(|path| self.get(path))
.collect::<FsResult<Vec<ImfsEntry>>>(); .collect::<FsResult<Vec<ImfsEntry>>>()
} } else {
dir.children_enumerated = true;
self.fetcher self.fetcher
.read_children(path) .read_children(path)
@@ -245,6 +247,7 @@ impl<F: ImfsFetcher> Imfs<F> {
.map(|path| self.get(path)) .map(|path| self.get(path))
.collect::<FsResult<Vec<ImfsEntry>>>() .collect::<FsResult<Vec<ImfsEntry>>>()
} }
}
ImfsItem::File(_) => Err(FsError::new( ImfsItem::File(_) => Err(FsError::new(
io::Error::new(io::ErrorKind::Other, "Can't read a directory"), io::Error::new(io::ErrorKind::Other, "Can't read a directory"),
path.to_path_buf(), path.to_path_buf(),