mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #386 from Flow-Launcher/fix_windowsindex_exclude
Fix exclusion of Windows Index search for files and folders
This commit is contained in:
commit
647e2b4ef8
3 changed files with 42 additions and 3 deletions
|
|
@ -109,6 +109,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForFileContentSearch,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
}
|
||||
|
|
@ -144,6 +145,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return await IndexSearch.WindowsIndexSearchAsync(querySearchString,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForAllFilesAndFolders,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
}
|
||||
|
|
@ -155,6 +157,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
return await IndexSearch.WindowsIndexSearchAsync(path,
|
||||
queryConstructor.CreateQueryHelper().ConnectionString,
|
||||
queryConstructor.QueryForTopLevelDirectorySearch,
|
||||
settings.IndexSearchExcludedSubdirectoryPaths,
|
||||
query,
|
||||
token).ConfigureAwait(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||
using Microsoft.Search.Interop;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -83,7 +84,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
}
|
||||
|
||||
internal async static Task<List<Result>> WindowsIndexSearchAsync(string searchString, string connectionString,
|
||||
Func<string, string> constructQuery, Query query,
|
||||
Func<string, string> constructQuery,
|
||||
List<AccessLink> exclusionList,
|
||||
Query query,
|
||||
CancellationToken token)
|
||||
{
|
||||
var regexMatch = Regex.Match(searchString, reservedStringPattern);
|
||||
|
|
@ -92,8 +95,41 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
|
|||
return new List<Result>();
|
||||
|
||||
var constructedQuery = constructQuery(searchString);
|
||||
return await ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token);
|
||||
return await RemoveResultsInExclusionList(
|
||||
await ExecuteWindowsIndexSearchAsync(constructedQuery, connectionString, query, token),
|
||||
exclusionList);
|
||||
}
|
||||
|
||||
private async static Task<List<Result>> RemoveResultsInExclusionList(List<Result> results, List<AccessLink> exclusionList)
|
||||
{
|
||||
var indexExclusionListCount = exclusionList.Count;
|
||||
|
||||
if (indexExclusionListCount == 0)
|
||||
return results;
|
||||
|
||||
var filteredResults = new List<Result>();
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
for (var index = 0; index < results.Count; index++)
|
||||
{
|
||||
var excludeResult = false;
|
||||
|
||||
for (var i = 0; i < indexExclusionListCount; i++)
|
||||
{
|
||||
if (results[index].SubTitle.StartsWith(exclusionList[i].Path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
excludeResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!excludeResult)
|
||||
filteredResults.Add(results[index]);
|
||||
}
|
||||
});
|
||||
|
||||
return filteredResults;
|
||||
}
|
||||
|
||||
internal static bool PathIsIndexed(string path)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"Name": "Explorer",
|
||||
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
|
||||
"Author": "Jeremy Wu",
|
||||
"Version": "1.7.1",
|
||||
"Version": "1.7.2",
|
||||
"Language": "csharp",
|
||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",
|
||||
|
|
|
|||
Loading…
Reference in a new issue