From cabe944979b5680e7cfd52b65ecec958b4fdd11b Mon Sep 17 00:00:00 2001 From: Phoenix Date: Mon, 7 Aug 2023 15:18:49 +0300 Subject: [PATCH 1/2] Fix windows search empty paths --- .../Search/WindowsIndex/WindowsIndex.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs index 8aca5929df1..7dde4cf996e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs @@ -47,14 +47,14 @@ private static async IAsyncEnumerable ExecuteWindowsIndexSearchAsy while (await dataReader.ReadAsync(token)) { token.ThrowIfCancellationRequested(); - if (dataReader.GetValue(0) == DBNull.Value || dataReader.GetValue(1) == DBNull.Value) + if (dataReader.GetValue(0) is DBNull + || dataReader.GetValue(1) is not string rawFragmentPath + || string.Equals(rawFragmentPath, "file:", StringComparison.OrdinalIgnoreCase)) { continue; } // # is URI syntax for the fragment component, need to be encoded so LocalPath returns complete path - var encodedFragmentPath = dataReader - .GetString(1) - .Replace("#", "%23", StringComparison.OrdinalIgnoreCase); + var encodedFragmentPath = rawFragmentPath.Replace("#", "%23", StringComparison.OrdinalIgnoreCase); var path = new Uri(encodedFragmentPath).LocalPath; From ae18d12e42f9f18eafe1717ce483eca4df2e0fe7 Mon Sep 17 00:00:00 2001 From: Phoenix Date: Mon, 7 Aug 2023 15:54:30 +0300 Subject: [PATCH 2/2] Additional check for file extension in windows search results --- .../Search/WindowsIndex/WindowsIndex.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs index 7dde4cf996e..66230937cd3 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs @@ -49,7 +49,8 @@ private static async IAsyncEnumerable ExecuteWindowsIndexSearchAsy token.ThrowIfCancellationRequested(); if (dataReader.GetValue(0) is DBNull || dataReader.GetValue(1) is not string rawFragmentPath - || string.Equals(rawFragmentPath, "file:", StringComparison.OrdinalIgnoreCase)) + || string.Equals(rawFragmentPath, "file:", StringComparison.OrdinalIgnoreCase) + || dataReader.GetValue(2) is not string extension) { continue; } @@ -61,7 +62,7 @@ private static async IAsyncEnumerable ExecuteWindowsIndexSearchAsy yield return new SearchResult { FullPath = path, - Type = dataReader.GetString(2) == "Directory" ? ResultType.Folder : ResultType.File, + Type = string.Equals(extension, "Directory", StringComparison.Ordinal) ? ResultType.Folder : ResultType.File, WindowsIndexed = true }; }