Skip to content

Commit

Permalink
#209: Avoid extra pga.db checks in Lutris root detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jun 23, 2024
1 parent 23cec24 commit 0ebb6d4
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/resource/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,24 +1307,19 @@ impl Config {
let config_dir = StrictPath::new(config_dir.to_string());
let data_dir = StrictPath::new(data_dir.to_string());

let path = 'inner: {
for candidate in [&config_dir, &data_dir] {
let (path, db_candidate) = 'inner: {
for (candidate, db_candidate) in [(&config_dir, Some(&data_dir)), (&data_dir, None)] {
if !candidate.joined("games/*.y*ml").glob().is_empty() {
break 'inner candidate.rendered();
break 'inner (candidate.rendered(), db_candidate);
}
}
continue 'lutris;
};

let database = 'inner: {
for (candidate, include) in [(&path, false), (&config_dir, true), (&data_dir, true)] {
let candidate = candidate.joined("pga.db");
if candidate.is_file() {
break 'inner include.then_some(candidate.rendered());
}
}
None
};
let database = db_candidate.and_then(|candidate| {
let candidate = candidate.joined("pga.db");
candidate.is_file().then(|| candidate.rendered())
});

for root in &self.roots {
if let Root::Lutris(stored) = root {
Expand Down

0 comments on commit 0ebb6d4

Please sign in to comment.