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 authored and rami3l committed May 8, 2024
1 parent 5d8512e commit 2c0f86a
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 2c0f86a

Please sign in to comment.