mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Stop await indexing when indexing is required and cache exist
This commit is contained in:
parent
5e011db37b
commit
da3f20a61a
2 changed files with 22 additions and 24 deletions
|
|
@ -85,20 +85,20 @@ namespace Flow.Launcher.Plugin.Program
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
|
||||||
await Task.Run(() =>
|
_settings = _settingsStorage.Load();
|
||||||
{
|
|
||||||
_settings = _settingsStorage.Load();
|
|
||||||
|
|
||||||
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Preload programs cost", () =>
|
await Task.Yield();
|
||||||
{
|
|
||||||
_win32Storage = new BinaryStorage<Win32[]>("Win32");
|
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Preload programs cost", () =>
|
||||||
_win32s = _win32Storage.TryLoad(new Win32[] { });
|
{
|
||||||
_uwpStorage = new BinaryStorage<UWP.Application[]>("UWP");
|
_win32Storage = new BinaryStorage<Win32[]>("Win32");
|
||||||
_uwps = _uwpStorage.TryLoad(new UWP.Application[] { });
|
_win32s = _win32Storage.TryLoad(new Win32[] { });
|
||||||
});
|
_uwpStorage = new BinaryStorage<UWP.Application[]>("UWP");
|
||||||
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>");
|
_uwps = _uwpStorage.TryLoad(new UWP.Application[] { });
|
||||||
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>");
|
|
||||||
});
|
});
|
||||||
|
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>");
|
||||||
|
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>");
|
||||||
|
|
||||||
|
|
||||||
bool indexedWinApps = false;
|
bool indexedWinApps = false;
|
||||||
bool indexedUWPApps = false;
|
bool indexedUWPApps = false;
|
||||||
|
|
@ -121,16 +121,19 @@ namespace Flow.Launcher.Plugin.Program
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await Task.WhenAll(a, b);
|
var indexTask = Task.WhenAll(a, b).ContinueWith(t =>
|
||||||
|
{
|
||||||
if (indexedWinApps && indexedUWPApps)
|
if (indexedWinApps && indexedUWPApps)
|
||||||
_settings.LastIndexTime = DateTime.Today;
|
_settings.LastIndexTime = DateTime.Today;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!(_win32s.Any() && _uwps.Any()))
|
||||||
|
await indexTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IndexWin32Programs()
|
public static void IndexWin32Programs()
|
||||||
{
|
{
|
||||||
var win32S = Win32.All(_settings);
|
var win32S = Win32.All(_settings);
|
||||||
|
|
||||||
_win32s = win32S;
|
_win32s = win32S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,20 +141,15 @@ namespace Flow.Launcher.Plugin.Program
|
||||||
{
|
{
|
||||||
var windows10 = new Version(10, 0);
|
var windows10 = new Version(10, 0);
|
||||||
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
||||||
|
|
||||||
var applications = support ? UWP.All() : new UWP.Application[] { };
|
var applications = support ? UWP.All() : new UWP.Application[] { };
|
||||||
|
|
||||||
_uwps = applications;
|
_uwps = applications;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task IndexPrograms()
|
public static async Task IndexPrograms()
|
||||||
{
|
{
|
||||||
var t1 = Task.Run(IndexWin32Programs);
|
var t1 = Task.Run(IndexWin32Programs);
|
||||||
|
|
||||||
var t2 = Task.Run(IndexUwpPrograms);
|
var t2 = Task.Run(IndexUwpPrograms);
|
||||||
|
|
||||||
await Task.WhenAll(t1, t2).ConfigureAwait(false);
|
await Task.WhenAll(t1, t2).ConfigureAwait(false);
|
||||||
|
|
||||||
_settings.LastIndexTime = DateTime.Today;
|
_settings.LastIndexTime = DateTime.Today;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,4 +243,4 @@ namespace Flow.Launcher.Plugin.Program
|
||||||
await IndexPrograms();
|
await IndexPrograms();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"Name": "Program",
|
"Name": "Program",
|
||||||
"Description": "Search programs in Flow.Launcher",
|
"Description": "Search programs in Flow.Launcher",
|
||||||
"Author": "qianlifeng",
|
"Author": "qianlifeng",
|
||||||
"Version": "1.4.3",
|
"Version": "1.4.4",
|
||||||
"Language": "csharp",
|
"Language": "csharp",
|
||||||
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
|
||||||
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",
|
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue