Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Apr 7, 2024
1 parent 99f6156 commit aa05f54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ impl StrictPath {
}

pub fn nearest_prefix(&self, others: Vec<StrictPath>) -> Option<StrictPath> {
println!(":: nearest_prefix");
dbg!((&self, &others));
let (us_drive, us_parts) = self.analyze();
let us_count = us_parts.len();

Expand All @@ -651,6 +653,8 @@ impl StrictPath {
let (them_drive, them_parts) = other.analyze();
let them_len = them_parts.len();

dbg!((&us_drive, &us_parts, &them_drive, &them_parts));

if us_drive != them_drive || us_count <= them_len {
continue;
}
Expand Down
9 changes: 8 additions & 1 deletion src/resource/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,10 @@ impl ToggledPaths {
}

pub fn is_ignored(&self, game: &str, path: &StrictPath) -> bool {
println!(":: is_ignored");
let transitive = self.is_enabled_transitively(game, path);
let specific = self.is_enabled_specifically(game, path);
dbg!((game, path, transitive, specific));
match (transitive, specific) {
(_, Some(x)) => !x,
(Some(x), _) => !x,
Expand All @@ -1279,6 +1281,7 @@ impl ToggledPaths {
}

fn is_enabled_transitively(&self, game: &str, path: &StrictPath) -> Option<bool> {
println!(":: is_enabled_transitively");
self.0.get(game).and_then(|x| {
path.nearest_prefix(x.keys().cloned().collect())
.as_ref()
Expand All @@ -1287,11 +1290,15 @@ impl ToggledPaths {
}

fn is_enabled_specifically(&self, game: &str, path: &StrictPath) -> Option<bool> {
println!(":: is_enabled_specifically");
self.0.get(game).and_then(|x| match x.get(path) {
Some(enabled) => Some(*enabled),
None => x
.iter()
.find(|(k, _)| path.interpret() == k.interpret())
.find(|(k, _)| {
dbg!((path.interpret(), k.interpret()));
path.interpret() == k.interpret()
})
.map(|(_, v)| *v),
})
}
Expand Down

0 comments on commit aa05f54

Please sign in to comment.