Skip to content

Commit

Permalink
test if the path exists before telling the script that this file need…
Browse files Browse the repository at this point in the history
…s to be loaded. This fixes the bug where software with the same name exists in two different modulepaths
  • Loading branch information
Frederik Delaere committed Sep 14, 2018
1 parent b4df6a9 commit 52f58e0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/rsmodules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ fn module_action(rsmod: &mut Rsmodule, action: &str) {
if found && module.0.starts_with(mdl) && module.1 == 1 {
selected_module = module.0.as_ref();
let testpath = format!("{}/{}", modulepath, module.0);
modulefile = PathBuf::from(&testpath);
// if a modulefile is already found, don't overwrite it with a
// possible non existing file
if Path::new(&testpath).exists() && Path::new(&testpath).is_file() {
modulefile = PathBuf::from(&testpath);
}

break 'outer;
}
Expand All @@ -460,8 +464,11 @@ fn module_action(rsmod: &mut Rsmodule, action: &str) {
selected_module = module.0.as_ref();
found = true;
let testpath = format!("{}/{}", modulepath, module.0);
modulefile = PathBuf::from(&testpath);

// if a modulefile is already found, don't overwrite it with a
// possible non existing file
if Path::new(&testpath).exists() && Path::new(&testpath).is_file() {
modulefile = PathBuf::from(&testpath);
}
// don't break out of the outer loop, their might be a module
// file marked as D
//break 'outer;
Expand Down Expand Up @@ -515,7 +522,6 @@ fn module_action(rsmod: &mut Rsmodule, action: &str) {
}

// finaly load|unload|info the module

output(format!("# {} {}\n", action, selected_module));
run_modulefile(&modulefile, rsmod, selected_module, action);

Expand Down

0 comments on commit 52f58e0

Please sign in to comment.