updated appstate config loading process to read project config files.
This commit is contained in:
+19
-13
@@ -75,19 +75,6 @@ impl AppState {
|
||||
self.config
|
||||
.insert("servers".to_string(), line.trim().to_string());
|
||||
}
|
||||
"projects" => {
|
||||
let strs: Vec<&str> = parts[1].split(", ").collect();
|
||||
let mut paths = Vec::new();
|
||||
for path in strs {
|
||||
paths.push(PathBuf::from(path));
|
||||
}
|
||||
for path in paths {
|
||||
let mut new_project = Project::new();
|
||||
new_project.config_folder(path);
|
||||
new_project.load_config()?;
|
||||
self.projects.push(new_project);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if parts[0].len() > 1 {
|
||||
self.config
|
||||
@@ -97,6 +84,25 @@ impl AppState {
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut projet_folder_path = self.config_file.clone();
|
||||
projet_folder_path.pop();
|
||||
projet_folder_path.push("projects");
|
||||
let project_dir_reses = read_dir(projet_folder_path)?;
|
||||
for res in project_dir_reses {
|
||||
if let Ok(project_folder) = res {
|
||||
let project_folder_file_reses = read_dir(project_folder.path())?;
|
||||
for res in project_folder_file_reses {
|
||||
if let Ok(conf_file) = res {
|
||||
if conf_file.file_name().to_string_lossy() == "project.conf".to_string() {
|
||||
let mut new_project = Project::new();
|
||||
new_project.config_folder(conf_file.path());
|
||||
new_project.load_config()?;
|
||||
self.projects.push(new_project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user