Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RamFs entries returns directory entries as files #6

Closed
flaviojs opened this issue May 23, 2019 · 3 comments
Closed

RamFs entries returns directory entries as files #6

flaviojs opened this issue May 23, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@flaviojs
Copy link
Contributor

The version was bumped to 0.2 so I tried implementing a CaselessFs and found a problem with RamFs during my tests.

This code:

    let mut ram = RamFs::new();
    ram.touch("/a.txt", b"low a".to_vec());
    ram.touch("/A.TXT", b"high a".to_vec());
    ram.touch("/b/b.txt", b"low b".to_vec());
    ram.touch("/B/B.TXT", b"high b".to_vec());
    for entry in ram.entries("/").unwrap() {
        println!("{:?}", &entry);
    }

prints this:

Ok(Entry { name: "A.TXT", kind: File })
Ok(Entry { name: "a.txt", kind: File })
Ok(Entry { name: "B", kind: File })
Ok(Entry { name: "b", kind: File })

B and b are directories, not files.

@germangb germangb added the bug Something isn't working label May 23, 2019
@germangb
Copy link
Owner

Must be this (line 57):

mini-fs/src/index.rs

Lines 51 to 63 in e7887fe

// Polls the next directory entry
fn next_dir(&mut self) -> Option<<Self as Iterator>::Item> {
if let Some(ref mut iter) = self.dirs {
iter.next().map(|(n, _)| Entry {
name: n.as_os_str(),
meta: None,
kind: EntryKind::File,
})
} else {
None
}
}
}

the index.rs test should be updated to account for this

@germangb
Copy link
Owner

Should be fixed in 0.2.1

@flaviojs
Copy link
Contributor Author

Yup, it's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants