Skip to content

Commit

Permalink
fix(fs): Prevent deadlock when scope listeners are registered. (#1221)
Browse files Browse the repository at this point in the history
* fix(fs): Prevent deadlock when scope listeners are registered.

* block
  • Loading branch information
FabianLars authored Apr 22, 2024
1 parent cdd3aaf commit b115fd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-fs-scope-deadlock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fs": patch
---

Fixes an issue that caused the app to freeze when the `dialog`, `fs`, and `persisted-scope` plugins were used together.
16 changes: 10 additions & 6 deletions plugins/fs/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ impl Scope {
pub fn allow_directory<P: AsRef<Path>>(&self, path: P, recursive: bool) {
let path = path.as_ref();

let mut allowed = self.allowed.lock().unwrap();
allowed.push(path.to_path_buf());
allowed.push(path.join(if recursive { "**" } else { "*" }));
{
let mut allowed = self.allowed.lock().unwrap();
allowed.push(path.to_path_buf());
allowed.push(path.join(if recursive { "**" } else { "*" }));
}

self.emit(Event::PathAllowed(path.to_path_buf()));
}
Expand All @@ -79,9 +81,11 @@ impl Scope {
pub fn forbid_directory<P: AsRef<Path>>(&self, path: P, recursive: bool) {
let path = path.as_ref();

let mut denied = self.denied.lock().unwrap();
denied.push(path.to_path_buf());
denied.push(path.join(if recursive { "**" } else { "*" }));
{
let mut denied = self.denied.lock().unwrap();
denied.push(path.to_path_buf());
denied.push(path.join(if recursive { "**" } else { "*" }));
}

self.emit(Event::PathForbidden(path.to_path_buf()));
}
Expand Down

0 comments on commit b115fd2

Please sign in to comment.