mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Reset Cache and rewrite uwp detection logic
This commit is contained in:
parent
87e7ff5b53
commit
80eb0e4943
2 changed files with 34 additions and 17 deletions
|
|
@ -116,6 +116,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
{
|
||||
var win32S = Win32.All(_settings);
|
||||
_win32s = win32S;
|
||||
ResetCache();
|
||||
}
|
||||
|
||||
public static void IndexUwpPrograms()
|
||||
|
|
@ -126,6 +127,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
{
|
||||
};
|
||||
_uwps = applications;
|
||||
ResetCache();
|
||||
}
|
||||
|
||||
public static async Task IndexPrograms()
|
||||
|
|
@ -133,7 +135,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
var t1 = Task.Run(IndexWin32Programs);
|
||||
var t2 = Task.Run(IndexUwpPrograms);
|
||||
await Task.WhenAll(t1, t2).ConfigureAwait(false);
|
||||
ResetCache();
|
||||
_settings.LastIndexTime = DateTime.Today;
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +236,6 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public void Dispose()
|
||||
{
|
||||
Win32.Dispose();
|
||||
UWP.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ using Rect = System.Windows.Rect;
|
|||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading.Channels;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Program.Programs
|
||||
{
|
||||
|
|
@ -163,8 +164,10 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
catch (Exception e)
|
||||
{
|
||||
ProgramLogger.LogException($"|UWP|All|{p.InstalledLocation}|An unexpected error occured and "
|
||||
+ $"unable to convert Package to UWP for {p.Id.FullName}", e);
|
||||
return new Application[] { };
|
||||
+ $"unable to convert Package to UWP for {p.Id.FullName}", e);
|
||||
return new Application[]
|
||||
{
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#if DEBUG //make developer aware and implement handling
|
||||
|
|
@ -239,15 +242,37 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
}
|
||||
}
|
||||
|
||||
private static List<FileSystemWatcher> _watchers = new();
|
||||
private static Channel<byte> PackageChangeChannel = Channel.CreateBounded<byte>(1);
|
||||
|
||||
public static void WatchPackageChange()
|
||||
public static async Task WatchPackageChange()
|
||||
{
|
||||
if (Environment.OSVersion.Version.Build >= 19041)
|
||||
PackageCatalog.OpenForCurrentUser().PackageStatusChanged += (_, _) =>
|
||||
if (Environment.OSVersion.Version.Major >= 10)
|
||||
{
|
||||
var catalog = PackageCatalog.OpenForCurrentUser();
|
||||
catalog.PackageInstalling += (_, args) =>
|
||||
{
|
||||
Task.Delay(10000).ContinueWith(t => Main.IndexUwpPrograms());
|
||||
if (args.IsComplete)
|
||||
PackageChangeChannel.Writer.TryWrite(default);
|
||||
};
|
||||
catalog.PackageUninstalling += (_, args) =>
|
||||
{
|
||||
if (args.IsComplete)
|
||||
PackageChangeChannel.Writer.TryWrite(default);
|
||||
};
|
||||
catalog.PackageUpdating += (_, args) =>
|
||||
{
|
||||
if (args.IsComplete)
|
||||
PackageChangeChannel.Writer.TryWrite(default);
|
||||
};
|
||||
|
||||
while (await PackageChangeChannel.Reader.WaitToReadAsync().ConfigureAwait(false))
|
||||
{
|
||||
await Task.Delay(3000).ConfigureAwait(false);
|
||||
PackageChangeChannel.Reader.TryRead(out _);
|
||||
await Task.Run(Main.IndexUwpPrograms);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
@ -750,14 +775,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
}
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
foreach (var fileSystemWatcher in _watchers)
|
||||
{
|
||||
fileSystemWatcher.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public enum PackageVersion
|
||||
{
|
||||
Windows10,
|
||||
|
|
|
|||
Loading…
Reference in a new issue