From f59e2399b9d0a58ea59eac2cdee87810a9fcb350 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 6 Jun 2025 13:25:43 +0800 Subject: [PATCH] Add error handling for directory operation --- .../FirefoxBookmarkLoader.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs index 61fd05073..ac382275f 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs @@ -294,16 +294,22 @@ public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase { var platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var packagesPath = Path.Combine(platformPath, "Packages"); - - // Search for folder with Mozilla.Firefox prefix - var firefoxPackageFolder = Directory.EnumerateDirectories(packagesPath, "Mozilla.Firefox*", - SearchOption.TopDirectoryOnly).FirstOrDefault(); + try + { + // Search for folder with Mozilla.Firefox prefix + var firefoxPackageFolder = Directory.EnumerateDirectories(packagesPath, "Mozilla.Firefox*", + SearchOption.TopDirectoryOnly).FirstOrDefault(); - // Msix FireFox not installed - if (firefoxPackageFolder == null) return string.Empty; + // Msix FireFox not installed + if (firefoxPackageFolder == null) return string.Empty; - var profileFolderPath = Path.Combine(firefoxPackageFolder, @"LocalCache\Roaming\Mozilla\Firefox"); - return GetProfileIniPath(profileFolderPath); + var profileFolderPath = Path.Combine(firefoxPackageFolder, @"LocalCache\Roaming\Mozilla\Firefox"); + return GetProfileIniPath(profileFolderPath); + } + catch + { + return string.Empty; + } } }