Skip to content

Commit

Permalink
Merge branch 'main' into 61-bug-cuda-dlls
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgv authored Sep 16, 2023
2 parents 5b51725 + 3e2d838 commit 006cd5a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions apps/desktop/src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,29 @@ impl State {
&self,
sub_path: &str,
) -> Result<String, String> {
Ok(
Ok({
get_app_dir_path_buf(self.1.clone(), sub_path)?
.display()
.to_string(),
)
.to_string()
})
}
pub fn read(&self, key: ConfigKey) -> Result<String, String> {
self.get(&key.to_string())?.data.ok_or(match key {
ConfigKey::ModelsDirectory => {
self.make_default_directory_string("models")?
}
ConfigKey::ThreadsDirectory => {
self.make_default_directory_string("threads")?
}
match self.get(&key.to_string()) {
Ok(val) => Ok(val.data.unwrap_or_else(|| self.default_for_key(&key))),
Err(_) => Ok(self.default_for_key(&key)),
}
}

fn default_for_key(&self, key: &ConfigKey) -> String {
match key {
ConfigKey::ModelsDirectory => self
.make_default_directory_string("models")
.unwrap_or_default(),
ConfigKey::ThreadsDirectory => self
.make_default_directory_string("threads")
.unwrap_or_default(),
_ => "".to_string(),
})
}
}

pub fn write(&self, key: ConfigKey, data: &str) -> Result<(), String> {
Expand Down

0 comments on commit 006cd5a

Please sign in to comment.