Skip to content

Commit dce1cb5

Browse files
committed
fix: installation-folder - thanks pixel
1 parent b9735f5 commit dce1cb5

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/utils.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::structs::Instance;
2+
use directories::{BaseDirs, UserDirs};
23
use regex::Regex;
34
use std::io::Read;
4-
use directories::{BaseDirs, UserDirs};
55

66
pub mod progress {
77
use indicatif::{ProgressBar, ProgressStyle};
@@ -83,7 +83,7 @@ pub fn get_instance_paths() -> Vec<Instance> {
8383
let bsm_config_file = std::fs::File::open(bsm_config_path).unwrap();
8484
let bsm_config: serde_json::Value = serde_json::from_reader(bsm_config_file).unwrap();
8585

86-
if bsm_config["installation_folder"].as_str().is_none() {
86+
if bsm_config["installation-folder"].as_str().is_none() {
8787
let bs_manager = documents_dir.join("BSManager").join("BSInstances");
8888

8989
for entry in std::fs::read_dir(bs_manager).unwrap() {
@@ -94,7 +94,24 @@ pub fn get_instance_paths() -> Vec<Instance> {
9494
instances.push(Instance {
9595
name: path.file_name().unwrap().to_str().unwrap().to_string(),
9696
game_version: get_game_version(path.to_str().unwrap().to_string()),
97-
path
97+
path,
98+
});
99+
}
100+
}
101+
} else {
102+
let base_path = bsm_config["installation-folder"].as_str().unwrap();
103+
let mut bs_manager = std::path::Path::new(base_path).join("BSManager");
104+
bs_manager.push("BSInstances");
105+
106+
for entry in std::fs::read_dir(base_path).unwrap() {
107+
let entry = entry.unwrap();
108+
let path = entry.path();
109+
110+
if path.is_dir() {
111+
instances.push(Instance {
112+
name: path.file_name().unwrap().to_str().unwrap().to_string(),
113+
game_version: get_game_version(path.to_str().unwrap().to_string()),
114+
path,
98115
});
99116
}
100117
}

0 commit comments

Comments
 (0)