Skip to content

Commit

Permalink
Make settings file allow multiple borrows
Browse files Browse the repository at this point in the history
  • Loading branch information
majaha committed Jan 11, 2024
1 parent af6bf2b commit c752b65
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ impl SettingsFile {
fn read_settings(&self) -> Result<()> {
let mut needs_save = false;
{
let mut b = self.cache.borrow_mut();
let b = self.cache.borrow();
if b.is_none() {
*b = Some(if utils::is_file(&self.path) {
drop(b);
*self.cache.borrow_mut() = Some(if utils::is_file(&self.path) {
let content = utils::read_file("settings", &self.path)?;
Settings::parse(&content)?
} else {
Expand Down

0 comments on commit c752b65

Please sign in to comment.