Skip to content

Commit 7819171

Browse files
authored
Merge pull request #2271 from Phoenix-/dev
Fix windows search empty paths
2 parents 1f1940a + ae18d12 commit 7819171

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,22 @@ private static async IAsyncEnumerable<SearchResult> ExecuteWindowsIndexSearchAsy
4747
while (await dataReader.ReadAsync(token))
4848
{
4949
token.ThrowIfCancellationRequested();
50-
if (dataReader.GetValue(0) == DBNull.Value || dataReader.GetValue(1) == DBNull.Value)
50+
if (dataReader.GetValue(0) is DBNull
51+
|| dataReader.GetValue(1) is not string rawFragmentPath
52+
|| string.Equals(rawFragmentPath, "file:", StringComparison.OrdinalIgnoreCase)
53+
|| dataReader.GetValue(2) is not string extension)
5154
{
5255
continue;
5356
}
5457
// # is URI syntax for the fragment component, need to be encoded so LocalPath returns complete path
55-
var encodedFragmentPath = dataReader
56-
.GetString(1)
57-
.Replace("#", "%23", StringComparison.OrdinalIgnoreCase);
58+
var encodedFragmentPath = rawFragmentPath.Replace("#", "%23", StringComparison.OrdinalIgnoreCase);
5859

5960
var path = new Uri(encodedFragmentPath).LocalPath;
6061

6162
yield return new SearchResult
6263
{
6364
FullPath = path,
64-
Type = dataReader.GetString(2) == "Directory" ? ResultType.Folder : ResultType.File,
65+
Type = string.Equals(extension, "Directory", StringComparison.Ordinal) ? ResultType.Folder : ResultType.File,
6566
WindowsIndexed = true
6667
};
6768
}

0 commit comments

Comments
 (0)