Skip to content

Commit 1f99012

Browse files
committed
Fix dependency check for optional dependencies
1 parent 0b376a3 commit 1f99012

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

mbf-agent/src/mod_man/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,6 @@ impl<'cache> ModManager<'cache> {
689689
Some(dep_rc) => {
690690
let dep_ref = dep_rc.borrow();
691691

692-
// Check if the dependency is within the required version range, if not then the mod definitely isn't installed.
693-
if !dependency.version_range.matches(&dep_ref.manifest().version) {
694-
return Ok(false);
695-
}
696-
697692
// If the dependency exists and is within the required range, we need to verify that it is installed also
698693
if !match dep_ref.installed {
699694
None => {
@@ -703,10 +698,14 @@ impl<'cache> ModManager<'cache> {
703698
}
704699
Some(installed) => installed,
705700
} {
701+
// If dependency not installed, mod is installed only if the dependency is optional (i.e. non required)
702+
return Ok(!dependency.required);
703+
} else if !dependency.version_range.matches(&dep_rc.borrow().manifest().version) { // If dependency is installed
704+
// If dependency not within required range needs fixing no matter if the dependency is required.
706705
return Ok(false);
707706
}
708707
}
709-
None => return Ok(false),
708+
None => return Ok(!dependency.required), // If dependency not present, the mod is still installed if the dependency isn't required
710709
}
711710
}
712711

0 commit comments

Comments
 (0)