From 0bba8b2ec05da78aa4efe80ce86c3ea839372a72 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Tue, 24 Sep 2024 21:22:42 +0200 Subject: [PATCH] desktop: Do not ask for filesystem access for files in SWF's directory --- desktop/src/backends/navigator.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/desktop/src/backends/navigator.rs b/desktop/src/backends/navigator.rs index f8f1d5b3392e..e63cbddb2ecc 100644 --- a/desktop/src/backends/navigator.rs +++ b/desktop/src/backends/navigator.rs @@ -37,13 +37,19 @@ impl DesktopNavigatorInterface { movie_path: Option, filesystem_access_mode: FilesystemAccessMode, ) -> Self { + let mut allowed_paths = Vec::new(); + if let Some(movie_path) = movie_path { + if let Some(parent) = movie_path.parent() { + // TODO Be smarter here, we do not necessarily want to allow + // access to the SWF's dir, but we also do not want to present + // the dialog to the user too often. + allowed_paths.push(parent.to_path_buf()); + } + allowed_paths.push(movie_path); + } Self { event_loop: Arc::new(Mutex::new(event_loop)), - allowed_paths: Arc::new(Mutex::new(if let Some(movie_path) = movie_path { - vec![movie_path] - } else { - Vec::new() - })), + allowed_paths: Arc::new(Mutex::new(allowed_paths)), filesystem_access_mode, } }