From 92679380186e41d30b3a4815445cbc896a29ddb7 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 25 Nov 2022 13:25:12 -0600 Subject: [PATCH] Append Result for everything error and windows index error --- .../Exceptions/EngineNotAvailableException.cs | 21 +++- .../Images/error.png | Bin 0 -> 4191 bytes .../Images/everything_error.png | Bin 0 -> 3039 bytes .../Images/index_error.png | Bin 0 -> 3966 bytes .../Images/index_error2.png | Bin 0 -> 5349 bytes .../Images/robot_error.png | Bin 0 -> 3309 bytes Plugins/Flow.Launcher.Plugin.Explorer/Main.cs | 23 +++-- .../Search/Constants.cs | 4 + .../Search/Everything/EverythingAPI.cs | 21 +++- .../Everything/EverythingApiDllImport.cs | 5 +- .../Everything/EverythingDownloadHelper.cs | 18 ++-- .../Everything/EverythingSearchManager.cs | 97 ++++++++++++++---- .../Search/WindowsIndex/WindowsIndex.cs | 75 +------------- 13 files changed, 144 insertions(+), 120 deletions(-) create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Images/error.png create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Images/everything_error.png create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Images/index_error.png create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Images/index_error2.png create mode 100644 Plugins/Flow.Launcher.Plugin.Explorer/Images/robot_error.png diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Exceptions/EngineNotAvailableException.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Exceptions/EngineNotAvailableException.cs index 04b200545..340877bd1 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Exceptions/EngineNotAvailableException.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Exceptions/EngineNotAvailableException.cs @@ -1,5 +1,10 @@ -using System; +#nullable enable + +using System; +using System.Threading.Tasks; +using System.Windows; using Flow.Launcher.Plugin.Explorer.Search.IProvider; +using JetBrains.Annotations; namespace Flow.Launcher.Plugin.Explorer.Exceptions; @@ -7,14 +12,24 @@ public class EngineNotAvailableException : Exception { public string EngineName { get; } public string Resolution { get; } + public Func>? Action { get; } + + public string? ErrorIcon { get; init; } + public EngineNotAvailableException(string engineName, string resolution, - string message) : base(message) + string message, + Func> action = null) : base(message) { EngineName = engineName; Resolution = resolution; + Action = action ?? (_ => + { + Clipboard.SetDataObject(this.ToString()); + return ValueTask.FromResult(true); + }); } - + public EngineNotAvailableException(string engineName, string resolution, string message, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/error.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/error.png new file mode 100644 index 0000000000000000000000000000000000000000..3b17d925b3f23003543250ae0711cf426e247ba3 GIT binary patch literal 4191 zcmV-l5TNggP)z~)Z)yo$wq`F_DK{R(j z6S4ePq}rM6l5XOHoNlGW*d)+8IDiG*+tkc#H9sz+8Mbzk^%%GSjQf{7Rbf&P3Bc)3lA(Y4hARx3Jg5tr_WzDU)|$EB`VXN+yG4 z86IWWZ;iEOrye8C{!gg!IkaI)^m#ZsMH!GFA+BhhcaZ&@a4h4UW13bA0Qz*!iGthB z^;fmhJ8;J@aIkB(2RoYt7y`Jfz$Yt#>69D*UVxS)!Z51nW&l$GoeB;pFIAfqla{82 ziI%ikFTqXgaeB8R{V=xM&_-ut(0Vq2qkSKM-qc#%0nn%PiRkny>hB?HCgn@G0&kAk z1uw^3UdNvV5A4Bn2AYZn`-u9m1w$-Wl-!LDe+LP_ho1BPp9Fwds_PW1H!#+3G!r#6 z&;!sIsDP$wb}irqxQYrn@(wZBWrLC^(x;g~MtX#>AgVUNzsX9yf$i1r2glLg_;C#G zci`juG2_Py@ZKgKraZ90z6;!dCvpho0w<@*Cc)o+ylb$>h}dyBdPp<>?!?r}@?cs9fqju2wtw;U?=C2TMG zAPJD*tv`ftJ`Tzc$gDSwMt1>}v(C1hvkTnrTj>LjTP$Uf-zUczJA{^95e*TGhUP)g zjqMU~ii`oZEB zw)BN?L4VWqJQrtwG9AWR4oJZ2Jxz5lo_T&>Phr~FrFe8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)wTVixFOxSRNkoJy%hjTwf1Z6TWuO?M13as6Ik1 z`;I~G54Xg`CYw1;w$qe8vPw~%`_1bSDS!0fq&h#Zu;5@hn`ThU7q|bh$dV(;Xs#iA zeHE&Bdougz`7E{lJV`T;7IS_%yT9KlII(hZ8GF|}{$7%_wV-bQPDNA2) zq-wl;+!(-%+~fE;99|rg`y(NMu_Acbg?P#@M<+FjPH@ZO+~SEk^W>Q2062&BhQ3*) zI>)D@{KVFePMM95#zw?VC_}PA!siSB{0CAYciqx;Rpd z8EAG29U_Z>5^3+7YS1CbJ+s=3E?=1m_#+`evDQngp%^cpO6l-><2rXOy$TOEIl^Hg z#VMl;y*StL@v2QD-x!Sp^nWHB66TH(tIN?=8_}KN?})z{!fUrfsy;1_#Q|`_ezaCv zU&I(oq=cNqq5JGdo$MB4wld+wghs^9XS53%`!vk{_9Mk}v|o+w#vqnqDA!N6>D~7x zGzl?U83m=Qfuah^T-p2NC{}3QQIP^%K)*ZDpovuP!(?2Kdp)8#E<+TH_b0Y08;M6P@rdVUOAXUlY&zS~c| zeCAN?#kTcilSV2&iq?e&EC;CAq?v}`vaQ64Rk(PvcyB#AGi7N~mDN-nEm!eUPL+a_ znU(-XQdm=IRr|FEk9icYdqibCB5RGx)N5vix0vKPH-G$hCDU{_fSoFM!HZLmIgr#0rvQ4s8RY{wo@{73Clp0OTs5D&$aHnRh7USANfLefF^RS&$%={SV8Jd6L{9c@R p4IbPpIDQep-zH-Epnm@qU;u-Ifjp{_^Wy*j002ovPDHLkV1mMwAEN*O literal 0 HcmV?d00001 diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/everything_error.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/everything_error.png new file mode 100644 index 0000000000000000000000000000000000000000..ad3eab179730a987709c29a1f5e546e3f8a40e01 GIT binary patch literal 3039 zcmV<53n27~P)(CAk7 zC`_=GN!xg(6gFA{rA>f9!?OgO2Z??EopbNC<2bgjlUxTRcEnNcweRCU@9&)72q`6Q z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8PS>m-Rq%-O zLEp*viVJ!N{c)yB4(|#fd6E=61USF0xX^(k+y0G4X9{vTCv@G=1m0{67ftK@_(}nr zLpA;Nrq=j$D+m3(qSkJgQR5>r1fo|G8Kox}c+l0UkjIH;nE(*-8~A)fPp`JC8$P8? z7}`ojP3+=;c=%k4{kN%3SqrHL@qh{#1cl)xF9dudWFK(Qk0I#ZzV0sNZ8}&hA~Yrb h|G&p?bNZhE0{~+%9HZz!&1C=p002ovPDHLkV1mMmrLF(~ literal 0 HcmV?d00001 diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/index_error.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/index_error.png new file mode 100644 index 0000000000000000000000000000000000000000..518d1d75d217b86dc8a42c05f1228b3f1a66cc84 GIT binary patch literal 3966 zcmV-^4}tKBP)AW1|)RCwC#TM3LD)tUZZRdrY2bI;i0 z8GFVa8+&{(V6Y&G9gcul6NKVGOi0iwN)!}nwUIa3UE;*fwIDXaMEy^1oMAea+P~p23mugP&JbU0w6O??2yP z4PlJIdwEFk9v@c;xJtlP0el+3gjc$X}IgZ?neeJDFo{Bzv@ zjziG1D90AV02>Mj03x}XK61u!pN4VwzC>7d2PN{X>oQ2Tkf_4Yjcs#AarC1zN)C2A9 z*Fak^2$U#b;i4?`025bdAq$bZ2B3I>TSast3RZL&R-h76Sq)m78qh_g1%b9KbT`8Q z11%4q-9sI>tA>CDfp$kCorQQtgSRhD!19%Aprf%7fy-c05P-$(fTv=y3>Yq4@pz%W zr46ixW*8j40CoDLh!-oDHG_igQ59&D$Cv_WFgXDz+|sHdAQp=~apcI+zw7MmBrDq5 z!9>l>r-90~Hkrx7xsf=m@7@A|KnOJr0<=k)&^!mu2`GT){}k57P~!@;w0A*rVg#b` zA#t^%wME2<*+J(Kv{43{3%3NT0>_L5^!D~{f8~|mlHuWD$YQX%?Y7%s`;HI7+O_NE zB!frzct%If$Dn)TwcrZ`@jKuUFcmy21J7(kg#XJ#cBpM^fixb(l9xdBc%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9Zs~|VkSjrvwzUeTFepCJ-f?}encc*Fe z(OOBbmu9A}NjVSBz3Lr1z)9XyM%*s#R9)YUFJIc?IkcHVS;A~K08)T<(@RTFymu+y zsWNom{u=J*RIM3|dP0|P+kj~7(O*)ISYPKG&YxB5_mpW-9qO?b<_`-xDSg65lUwB? zZxdhk7qyPy)*#7ea#VZ1V_Vb@`-}>rX2kx^Pwa*fV{Epiuvl0*U3PoXY{X^dXvWeZYRFkG$JfV$((jcI8+{NGf_E>jizo_> z6pXHCMa3^JpUZ6j+4V$_E<0RYB9M4GrLI!TFHZH{;>7lexpv>5E4XT{d6SH#%<5sA zv-lZ#T?@e%W7f~4XWQg-JOIP18=aGb+fq|gcwqKS@WO$m;=VS|vdLMfz;lq3K2!d? zo}|XBb~019Jn&t}4Cdz$71fhf#cl}#=OrIrd=Om{ZP29J&#Hr$b7CqYnkzy!T9NX3 zd0m%JiU{|ECiULD1i3nWy0`D=*)`1yfRXC?V z9S|)BuNMIQ?UUI&ZmqsmJvB2a2n)qTq8+~!M0%OZ(6?J&XzD?_s!-|*DBK(&c2pmu+oP;+;dqIqLiv1 z*F4_e!Wj;Jq?M&xbi7dC>W;XSY4e4{Bc*(LmxS1vX>I7lHvH+Zol^SZd;MIDM?24h z-nt(T-A4^v3(WU|o@Pe)G0Zk-<+T7ifkPdxW^=O1Y%4n1t51qPe7sfJD|fT5+Zs`T zMFV6Rh$4v0J?k32#b_yB^ZwILrYeK{Yt{)V0fM21W412Q+q*f`&!Sa=Pkz|>5ovhR K6kDj{df^`#m~cA) literal 0 HcmV?d00001 diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Images/robot_error.png b/Plugins/Flow.Launcher.Plugin.Explorer/Images/robot_error.png new file mode 100644 index 0000000000000000000000000000000000000000..6b4f83b42f2f4f4d503e041071825cfeb9336899 GIT binary patch literal 3309 zcmVlB#;9_0*Om5NP!C?Kq3($aY85v4v1imLXFeSySP12;GPU$h5HL9#H2YvvHG^&}A15&dd)`-5QzLf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in.Explorer/Main.cs index 7201347c4..e5b3ab625 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs @@ -81,25 +81,28 @@ namespace Flow.Launcher.Plugin.Explorer try { return await searchManager.SearchAsync(query, token); - } - catch (Exception e) when (e is SearchException or SearchException) + catch (Exception e) when (e is SearchException or EngineNotAvailableException) { return new List { new() { Title = e.Message, - SubTitle = e is EngineNotAvailableException engineException - ? engineException.Resolution + SubTitle = e is EngineNotAvailableException { Resolution: { } resolution } + ? resolution : "Enter to copy the message to clipboard", Score = 501, - IcoPath = Constants.ExplorerIconImagePath, - Action = _ => - { - Clipboard.SetDataObject(e.ToString()); - return true; - } + IcoPath = e is EngineNotAvailableException { ErrorIcon: { } iconPath } + ? iconPath + : Constants.GeneralSearchErrorImagePath, + AsyncAction = e is EngineNotAvailableException {Action: { } action} + ? action + : _ => + { + Clipboard.SetDataObject(e.ToString()); + return new ValueTask(true); + } } }; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs index 897033590..8d6a6a738 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Constants.cs @@ -18,6 +18,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search internal const string QuickAccessImagePath = "Images\\quickaccess.png"; internal const string RemoveQuickAccessImagePath = "Images\\removequickaccess.png"; internal const string ShowContextMenuImagePath = "Images\\contextmenu.png"; + internal const string EverythingErrorImagePath = "Images\\everything_error.png"; + internal const string IndexSearchWarningImagePath = "Images\\index_error.png"; + internal const string WindowsIndexErrorImagePath = "Images\\index_error2.png"; + internal const string GeneralSearchErrorImagePath = "Images\\robot_error.png"; internal const string ToolTipOpenDirectory = "Ctrl + Enter to open the directory"; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs index 7b47d6bea..cd3183e7b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -8,6 +8,8 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Forms.Design; +using Flow.Launcher.Plugin.Explorer.Exceptions; namespace Flow.Launcher.Plugin.Explorer.Search.Everything { @@ -87,6 +89,15 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything return fastSortOptionEnabled; } + public static async ValueTask IsEverythingRunningAsync(CancellationToken token = default) + { + await _semaphore.WaitAsync(token); + EverythingApiDllImport.Everything_GetMajorVersion(); + var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError; + _semaphore.Release(); + return result; + } + /// /// Searches the specified key word and reset the everything API afterwards /// @@ -101,21 +112,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything if (option.MaxCount < 0) throw new ArgumentOutOfRangeException(nameof(option.MaxCount), option.MaxCount, "MaxCount must be greater than or equal to 0"); - + await _semaphore.WaitAsync(token); - + if (token.IsCancellationRequested) yield break; - + try { - + if (option.Keyword.StartsWith("@")) { EverythingApiDllImport.Everything_SetRegex(true); option.Keyword = option.Keyword[1..]; } - + var builder = new StringBuilder(); builder.Append(option.Keyword); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs index 534afcb78..5b80819fa 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingApiDllImport.cs @@ -77,7 +77,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything [DllImport(DLL)] internal static extern int Everything_GetNumFileResults(); - + + [DllImport(DLL)] + internal static extern int Everything_GetMajorVersion(); + [DllImport(DLL)] internal static extern int Everything_GetNumFolderResults(); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs index 75bbd2b79..c5ecc250d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace Flow.Launcher.Plugin.Explorer.Search.Everything; -public class EverythingDownloadHelper +public static class EverythingDownloadHelper { public static async Task PromptDownloadIfNotInstallAsync(string installedLocation, IPublicAPI api) { @@ -21,15 +21,17 @@ public class EverythingDownloadHelper installedLocation = GetInstalledPath(); - if (string.IsNullOrEmpty(installedLocation) && - System.Windows.Forms.MessageBox.Show( - string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine), - api.GetTranslation("flowlauncher_plugin_everything_installing_title"), - System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) + if (string.IsNullOrEmpty(installedLocation)) { // Solves single thread apartment (STA) mode requirement error when using OpenFileDialog var t = new Thread(() => { + if (System.Windows.Forms.MessageBox.Show( + string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine), + api.GetTranslation("flowlauncher_plugin_everything_installing_title"), + System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) + return; + var dlg = new System.Windows.Forms.OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) @@ -51,7 +53,7 @@ public class EverythingDownloadHelper { return installedLocation; } - + api.ShowMsg(api.GetTranslation("flowlauncher_plugin_everything_installing_title"), api.GetTranslation("flowlauncher_plugin_everything_installing_subtitle"), "", useMainWindowAsOwner: false); @@ -96,4 +98,4 @@ public class EverythingDownloadHelper return File.Exists(scoopInstalledPath) ? scoopInstalledPath : string.Empty; } -} \ No newline at end of file +} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs index a1892e496..fd977edbe 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs @@ -1,9 +1,14 @@ using System; using Flow.Launcher.Plugin.Explorer.Search.WindowsIndex; using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; +using Flow.Launcher.Plugin.Explorer.Exceptions; +using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions; using Flow.Launcher.Plugin.Explorer.Search.IProvider; namespace Flow.Launcher.Plugin.Explorer.Search.Everything @@ -17,37 +22,85 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything Settings = settings; } - - public IAsyncEnumerable SearchAsync(string search, CancellationToken token) + private async ValueTask ThrowIfEverythingNotAvailableAsync(CancellationToken token = default) { - return EverythingApi.SearchAsync( - new EverythingSearchOption(search, Settings.SortOption), - token); + if (!await EverythingApi.IsEverythingRunningAsync(token)) + throw new EngineNotAvailableException( + Enum.GetName(Settings.IndexSearchEngineOption.Everything), + "Click to Open or Download Everything", + "Everything is not running.", + async _ => + { + var installedPath = await EverythingDownloadHelper.PromptDownloadIfNotInstallAsync(Settings.EverythingInstalledPath, Main.Context.API); + if (installedPath == null) + { + Main.Context.API.ShowMsgError("Unable to find Everything.exe"); + return false; + } + Settings.EverythingInstalledPath = installedPath; + Process.Start(installedPath, "-startup"); + return true; + }) + { + ErrorIcon = Constants.EverythingErrorImagePath + }; } - public IAsyncEnumerable ContentSearchAsync(string plainSearch, - string contentSearch, CancellationToken token) + + public async IAsyncEnumerable SearchAsync(string search, [EnumeratorCancellation] CancellationToken token) { + await ThrowIfEverythingNotAvailableAsync(token); + if (token.IsCancellationRequested) + yield break; + var option = new EverythingSearchOption(search, Settings.SortOption); + await foreach (var result in EverythingApi.SearchAsync(option, token)) + yield return result; + } + public async IAsyncEnumerable ContentSearchAsync(string plainSearch, + string contentSearch, [EnumeratorCancellation] CancellationToken token) + { + await ThrowIfEverythingNotAvailableAsync(token); if (!Settings.EnableEverythingContentSearch) { - return AsyncEnumerable.Empty(); + throw new EngineNotAvailableException(Enum.GetName(Settings.IndexSearchEngineOption.Everything), + "Click to Enable Everything Content Search (only applicable to Everything 1.5+ with indexed content)", + "Everything Content Search is not enabled.", + _ => + { + Settings.EnableEverythingContentSearch = true; + return ValueTask.FromResult(true); + }) + { + ErrorIcon = Constants.EverythingErrorImagePath + }; } + if (token.IsCancellationRequested) + yield break; - return EverythingApi.SearchAsync( - new EverythingSearchOption( - plainSearch, - Settings.SortOption, - true, - contentSearch), - token); + var option = new EverythingSearchOption(plainSearch, + Settings.SortOption, + true, + contentSearch); + + await foreach (var result in EverythingApi.SearchAsync(option, token)) + { + yield return result; + } } - public IAsyncEnumerable EnumerateAsync(string path, string search, bool recursive, CancellationToken token) + public async IAsyncEnumerable EnumerateAsync(string path, string search, bool recursive, [EnumeratorCancellation] CancellationToken token) { - return EverythingApi.SearchAsync( - new EverythingSearchOption(search, - Settings.SortOption, - ParentPath: path, - IsRecursive: recursive), - token); + await ThrowIfEverythingNotAvailableAsync(token); + if (token.IsCancellationRequested) + yield break; + + var option = new EverythingSearchOption(search, + Settings.SortOption, + ParentPath: path, + IsRecursive: recursive); + + await foreach (var result in EverythingApi.SearchAsync(option, token)) + { + yield return result; + } } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs index 9028c6d16..f7a4a019b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/WindowsIndex.cs @@ -1,5 +1,4 @@ using Flow.Launcher.Infrastructure.Logger; -using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Microsoft.Search.Interop; using System; using System.Collections.Generic; @@ -10,7 +9,6 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using System.Windows; using Flow.Launcher.Plugin.Explorer.Exceptions; namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex @@ -96,21 +94,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex throw new EngineNotAvailableException("Windows Index", api.GetTranslation("plugin_explorer_windowsSearchServiceFix"), api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), - e); + e) + { + ErrorIcon = Constants.WindowsIndexErrorImagePath + }; } } - // TODO: Move to General Search Manager - private static void RemoveResultsInExclusionList(List results, IReadOnlyList exclusionList, CancellationToken token) - { - var indexExclusionListCount = exclusionList.Count; - - if (indexExclusionListCount == 0) - return; - results.RemoveAll(searchResult => - exclusionList.Any(exclude => searchResult.FullPath.StartsWith(exclude.Path, StringComparison.OrdinalIgnoreCase)) - ); - } internal static bool PathIsIndexed(string path) { @@ -127,63 +117,6 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex } } - // TODO: Use a custom exception to handle this - private static List ResultForWindexSearchOff(string rawQuery) - { - var api = SearchManager.Context.API; - return new List - { - new Result - { - Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), - SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"), - Action = c => - { - SearchManager.Settings.WarnWindowsSearchServiceOff = false; - - var pluginsManagerPlugin = api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7"); - - var actionKeywordCount = pluginsManagerPlugin.Metadata.ActionKeywords.Count; - - if (actionKeywordCount > 1) - LogException("PluginsManager's action keyword has increased to more than 1, this does not allow for determining the " + - "right action keyword. Explorer's code for managing Windows Search service not running exception needs to be updated", - new InvalidOperationException()); - - if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine), - api.GetTranslation("plugin_explorer_alternative_title"), - MessageBoxButton.YesNo) == MessageBoxResult.Yes - && actionKeywordCount == 1) - { - api.ChangeQuery($"{pluginsManagerPlugin.Metadata.ActionKeywords[0]} install everything"); - } - else - { - // Clears the warning message because same query string will not alter the displayed result list - api.ChangeQuery(string.Empty); - - api.ChangeQuery(rawQuery); - } - - var mainWindow = Application.Current.MainWindow!; - mainWindow.Show(); - mainWindow.Focus(); - - return false; - }, - IcoPath = Constants.ExplorerIconImagePath - } - }; - } - - private static void LogException(string message, Exception e) - { -#if DEBUG // Please investigate and handle error from index search - throw e; -#else - Log.Exception($"|Flow.Launcher.Plugin.Explorer.IndexSearch|{message}", e); -#endif - } } }