Move ReservedStringPattern to IndexSearcher class

This commit is contained in:
Jeremy Wu 2020-05-24 19:15:13 +10:00
parent 191efe31cb
commit 472f4a5f49
2 changed files with 14 additions and 11 deletions

View file

@ -1,4 +1,4 @@
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using Flow.Launcher.Plugin.Explorer.Views;
@ -16,9 +16,6 @@ namespace Flow.Launcher.Plugin.Explorer
private SettingsViewModel _viewModel;
// Reserved keywords in oleDB
private string ReservedStringPattern = @"^[\/\\\$\%]+$";
public Control CreateSettingPanel()
{
return new ExplorerSettings();
@ -44,10 +41,7 @@ namespace Flow.Launcher.Plugin.Explorer
if (string.IsNullOrEmpty(query.Search))
return results;
var regexMatch = Regex.Match(query.Search, ReservedStringPattern);
if (regexMatch.Success)
return results;
return new SearchManager(_settings, Context).Search(query);
return new SearchManager(_settings, Context).Search(query.Search);
}

View file

@ -1,4 +1,4 @@
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin.SharedCommands;
using Microsoft.Search.Interop;
using System;
@ -6,11 +6,14 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data.OleDb;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
{
internal class IndexSearcher
{
private readonly object _lock = new object();
public OleDbConnection conn;
public OleDbCommand command;
@ -18,8 +21,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
public OleDbDataReader dataReaderResults;
private PluginInitContext _context;
private readonly object _lock = new object();
// Reserved keywords in oleDB
private string ReservedStringPattern = @"^[\/\\\$\%]+$";
public IndexSearcher(PluginInitContext context)
{
@ -95,6 +99,11 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
internal List<Result> WindowsIndexSearch(string searchString, string connectionString, Func<string, string> constructQuery)
{
var regexMatch = Regex.Match(searchString, ReservedStringPattern);
if (regexMatch.Success)
return new List<Result>();
lock (_lock)
{
var constructedQuery = constructQuery(searchString);