fix(fs): Prevent deadlock when scope listeners are registered. (#1221)

* fix(fs): Prevent deadlock when scope listeners are registered.

* block
This commit is contained in:
Fabian-Lars
2024-04-22 20:09:12 +02:00
committed by GitHub
parent cdd3aafdc6
commit b115fd22e0
2 changed files with 15 additions and 6 deletions
+5
View File
@@ -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.
+10 -6
View File
@@ -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()));
}
@@ -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()));
}