mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2123 from VictoriousRaptor/BoostProgramInit
Reduce CPU and disk usage during Program plugin init
This commit is contained in:
commit
6655d837c3
3 changed files with 19 additions and 34 deletions
|
|
@ -88,21 +88,24 @@ namespace Flow.Launcher.Plugin.Program
|
|||
|
||||
bool cacheEmpty = !_win32s.Any() && !_uwps.Any();
|
||||
|
||||
var a = Task.Run(() =>
|
||||
if (cacheEmpty || _settings.LastIndexTime.AddHours(30) < DateTime.Now)
|
||||
{
|
||||
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Win32Program index cost", IndexWin32Programs);
|
||||
});
|
||||
|
||||
var b = Task.Run(() =>
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await IndexProgramsAsync().ConfigureAwait(false);
|
||||
WatchProgramUpdate();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost", IndexUwpPrograms);
|
||||
});
|
||||
WatchProgramUpdate();
|
||||
}
|
||||
|
||||
if (cacheEmpty)
|
||||
await Task.WhenAll(a, b);
|
||||
|
||||
Win32.WatchProgramUpdate(_settings);
|
||||
_ = UWP.WatchPackageChange();
|
||||
static void WatchProgramUpdate()
|
||||
{
|
||||
Win32.WatchProgramUpdate(_settings);
|
||||
_ = UWP.WatchPackageChange();
|
||||
}
|
||||
}
|
||||
|
||||
public static void IndexWin32Programs()
|
||||
|
|
@ -110,6 +113,8 @@ namespace Flow.Launcher.Plugin.Program
|
|||
var win32S = Win32.All(_settings);
|
||||
_win32s = win32S;
|
||||
ResetCache();
|
||||
_win32Storage.Save(_win32s);
|
||||
_settings.LastIndexTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public static void IndexUwpPrograms()
|
||||
|
|
@ -117,6 +122,8 @@ namespace Flow.Launcher.Plugin.Program
|
|||
var applications = UWP.All(_settings);
|
||||
_uwps = applications;
|
||||
ResetCache();
|
||||
_uwpStorage.Save(_uwps);
|
||||
_settings.LastIndexTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public static async Task IndexProgramsAsync()
|
||||
|
|
@ -131,7 +138,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPProgram index cost", IndexUwpPrograms);
|
||||
});
|
||||
await Task.WhenAll(a, b).ConfigureAwait(false);
|
||||
_settings.LastIndexTime = DateTime.Today;
|
||||
}
|
||||
|
||||
internal static void ResetCache()
|
||||
|
|
@ -199,7 +205,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
_ = Task.Run(() =>
|
||||
{
|
||||
IndexUwpPrograms();
|
||||
_settings.LastIndexTime = DateTime.Today;
|
||||
});
|
||||
}
|
||||
else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
|
||||
|
|
@ -210,7 +215,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
_ = Task.Run(() =>
|
||||
{
|
||||
IndexWin32Programs();
|
||||
_settings.LastIndexTime = DateTime.Today;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,13 +121,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public bool EnablePathSource { get; set; } = false;
|
||||
public bool EnableUWP { get; set; } = true;
|
||||
|
||||
public string CustomizedExplorer { get; set; } = Explorer;
|
||||
public string CustomizedArgs { get; set; } = ExplorerArgs;
|
||||
|
||||
internal const char SuffixSeparator = ';';
|
||||
|
||||
internal const string Explorer = "explorer";
|
||||
|
||||
internal const string ExplorerArgs = "%s";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,18 +87,6 @@ namespace Flow.Launcher.Plugin.Program.Views
|
|||
}
|
||||
}
|
||||
|
||||
public string CustomizedExplorerPath
|
||||
{
|
||||
get => _settings.CustomizedExplorer;
|
||||
set => _settings.CustomizedExplorer = value;
|
||||
}
|
||||
|
||||
public string CustomizedExplorerArg
|
||||
{
|
||||
get => _settings.CustomizedArgs;
|
||||
set => _settings.CustomizedArgs = value;
|
||||
}
|
||||
|
||||
public bool ShowUWPCheckbox => UWP.SupportUWP();
|
||||
|
||||
public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)
|
||||
|
|
|
|||
Loading…
Reference in a new issue