Skip to content

Commit 355035e

Browse files
committed
re-add warning when Windows Index service is off as a search result
1 parent 5ac2366 commit 355035e

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Exceptions/EngineNotAvailableException.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public class EngineNotAvailableException : Exception
1616

1717
public string? ErrorIcon { get; init; }
1818

19-
public EngineNotAvailableException(string engineName,
19+
public EngineNotAvailableException(
20+
string engineName,
2021
string resolution,
2122
string message,
2223
Func<ActionContext, ValueTask<bool>> action = null) : base(message)
@@ -30,7 +31,8 @@ public EngineNotAvailableException(string engineName,
3031
});
3132
}
3233

33-
public EngineNotAvailableException(string engineName,
34+
public EngineNotAvailableException(
35+
string engineName,
3436
string resolution,
3537
string message,
3638
Exception innerException) : base(message, innerException)

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ private static async IAsyncEnumerable<SearchResult> ExecuteWindowsIndexSearchAsy
7070
// Initial ordering, this order can be updated later by UpdateResultView.MainViewModel based on history of user selection.
7171
}
7272

73-
74-
75-
internal static IAsyncEnumerable<SearchResult> WindowsIndexSearchAsync(string connectionString,
73+
internal static IAsyncEnumerable<SearchResult> WindowsIndexSearchAsync(
74+
string connectionString,
7675
string search,
7776
CancellationToken token)
7877
{
@@ -87,21 +86,34 @@ internal static IAsyncEnumerable<SearchResult> WindowsIndexSearchAsync(string co
8786
{
8887
throw new SearchException("Windows Index", e.Message, e);
8988
}
90-
catch (COMException e)
89+
catch (COMException)
9190
{
91+
// Occurs because the Windows Indexing (WSearch) is turned off in services and unable to be used by Explorer plugin
92+
93+
if (!SearchManager.Settings.WarnWindowsSearchServiceOff)
94+
return AsyncEnumerable.Empty<SearchResult>();
95+
9296
var api = SearchManager.Context.API;
9397

94-
throw new EngineNotAvailableException("Windows Index",
98+
throw new EngineNotAvailableException(
99+
"Windows Index",
95100
api.GetTranslation("plugin_explorer_windowsSearchServiceFix"),
96101
api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"),
97-
e)
102+
c =>
103+
{
104+
SearchManager.Settings.WarnWindowsSearchServiceOff = false;
105+
106+
// Clears the warning message so user is not mistaken that it has not worked
107+
api.ChangeQuery(string.Empty);
108+
109+
return ValueTask.FromResult(false);
110+
})
98111
{
99112
ErrorIcon = Constants.WindowsIndexErrorImagePath
100113
};
101114
}
102115
}
103116

104-
105117
internal static bool PathIsIndexed(string path)
106118
{
107119
try
@@ -116,7 +128,5 @@ internal static bool PathIsIndexed(string path)
116128
return false;
117129
}
118130
}
119-
120-
121131
}
122132
}

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndexSearchManager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public WindowsIndexSearchManager(Settings settings)
2121
QueryHelper = QueryConstructor.CreateQueryHelper();
2222
}
2323

24-
private IAsyncEnumerable<SearchResult> WindowsIndexFileContentSearchAsync(ReadOnlySpan<char> querySearchString,
24+
private IAsyncEnumerable<SearchResult> WindowsIndexFileContentSearchAsync(
25+
ReadOnlySpan<char> querySearchString,
2526
CancellationToken token)
2627
{
2728
if (querySearchString.IsEmpty)
@@ -33,7 +34,8 @@ private IAsyncEnumerable<SearchResult> WindowsIndexFileContentSearchAsync(ReadOn
3334
token);
3435
}
3536

36-
private IAsyncEnumerable<SearchResult> WindowsIndexFilesAndFoldersSearchAsync(ReadOnlySpan<char> querySearchString,
37+
private IAsyncEnumerable<SearchResult> WindowsIndexFilesAndFoldersSearchAsync(
38+
ReadOnlySpan<char> querySearchString,
3739
CancellationToken token = default)
3840
{
3941
return WindowsIndex.WindowsIndexSearchAsync(
@@ -42,7 +44,8 @@ private IAsyncEnumerable<SearchResult> WindowsIndexFilesAndFoldersSearchAsync(Re
4244
token);
4345
}
4446

45-
private IAsyncEnumerable<SearchResult> WindowsIndexTopLevelFolderSearchAsync(ReadOnlySpan<char> search,
47+
private IAsyncEnumerable<SearchResult> WindowsIndexTopLevelFolderSearchAsync(
48+
ReadOnlySpan<char> search,
4649
ReadOnlySpan<char> path,
4750
bool recursive,
4851
CancellationToken token)

0 commit comments

Comments
 (0)