mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-05 03:30:03 +00:00
Fix Vfs::add_path
: Add insert filename
instead of path
into the `HashSet<Box<Path>>` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
b879c15c70
commit
b88e384f95
1 changed files with 5 additions and 2 deletions
|
@ -17,11 +17,14 @@ impl Vfs {
|
|||
/// * `path` - must be canonical, must not be empty.
|
||||
pub(super) fn add_path(&mut self, mut path: &Path) {
|
||||
while let Some(parent) = path.parent() {
|
||||
if let Some(path_str) = path.to_str() {
|
||||
// Since path has parent, it must have a filename
|
||||
let filename = path.file_name().unwrap();
|
||||
|
||||
if let Some(filename) = filename.to_str() {
|
||||
self.0
|
||||
.entry(parent.into())
|
||||
.or_insert_with(|| HashSet::with_capacity(4))
|
||||
.insert(path_str.into());
|
||||
.insert(filename.into());
|
||||
}
|
||||
|
||||
path = parent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue