Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows search empty paths #2271

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@
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)
|| dataReader.GetValue(2) is not string extension)
jjw24 marked this conversation as resolved.
Show resolved Hide resolved
{
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;

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
};
}
Expand Down Expand Up @@ -91,13 +92,13 @@
{
try
{
var csm = new CSearchManager();

Check warning on line 95 in Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`csm` is not a recognized word. (unrecognized-spelling)

Check warning on line 95 in Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`CSearch` is not a recognized word. (unrecognized-spelling)
var indexManager = csm.GetCatalog("SystemIndex").GetCrawlScopeManager();

Check warning on line 96 in Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`csm` is not a recognized word. (unrecognized-spelling)
return indexManager.IncludedInCrawlScope(path) > 0;
}
catch (COMException)
{
// Occurs because the Windows Indexing (WSearch) is turned off in services and unable to be used by Explorer plugin

Check warning on line 101 in Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`WSearch` is not a recognized word. (unrecognized-spelling)
return false;
}
}
Expand Down