mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
[CmdPal][App] Handle app indexing errors (#40717)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request #40100 OP is hitting an `AggregateException`. This PR aim to improve error handling and logging. It also remove some dead code 😄 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] **Closes:** #40100 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ca473b488b
commit
2398b5e6f0
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.Apps.Programs;
|
||||
@@ -46,7 +47,19 @@ public sealed partial class AppCache : IDisposable
|
||||
UpdateUWPIconPath(ThemeHelper.GetCurrentTheme());
|
||||
});
|
||||
|
||||
Task.WaitAll(a, b);
|
||||
try
|
||||
{
|
||||
Task.WaitAll(a, b);
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
ManagedCommon.Logger.LogError("One or more errors occurred while indexing apps");
|
||||
|
||||
foreach (var inner in ex.InnerExceptions)
|
||||
{
|
||||
ManagedCommon.Logger.LogError(inner.Message, inner);
|
||||
}
|
||||
}
|
||||
|
||||
AllAppsSettings.Instance.LastIndexTime = DateTime.Today;
|
||||
}
|
||||
@@ -57,7 +70,14 @@ public sealed partial class AppCache : IDisposable
|
||||
{
|
||||
foreach (UWPApplication app in _packageRepository)
|
||||
{
|
||||
app.UpdateLogoPath(theme);
|
||||
try
|
||||
{
|
||||
app.UpdateLogoPath(theme);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ManagedCommon.Logger.LogError($"Failed to update icon path for app {app.Name}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,14 +128,6 @@ public partial class UWP
|
||||
|
||||
public static UWPApplication[] All()
|
||||
{
|
||||
var windows10 = new Version(10, 0);
|
||||
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
||||
|
||||
if (!support)
|
||||
{
|
||||
return Array.Empty<UWPApplication>();
|
||||
}
|
||||
|
||||
var appsBag = new ConcurrentBag<UWPApplication>();
|
||||
|
||||
Parallel.ForEach(CurrentUserPackages(), p =>
|
||||
|
||||
@@ -115,11 +115,7 @@ internal sealed partial class PackageRepository : ListRepository<UWPApplication>
|
||||
|
||||
public void IndexPrograms()
|
||||
{
|
||||
var windows10 = new Version(10, 0);
|
||||
var support = Environment.OSVersion.Version.Major >= windows10.Major;
|
||||
|
||||
var applications = support ? Programs.UWP.All() : Array.Empty<UWPApplication>();
|
||||
|
||||
var applications = UWP.All();
|
||||
SetList(applications);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,8 +267,7 @@ internal sealed partial class Win32ProgramRepository : ListRepository<Programs.W
|
||||
|
||||
public void IndexPrograms()
|
||||
{
|
||||
var applications = Programs.Win32Program.All(_settings);
|
||||
|
||||
var applications = Win32Program.All(_settings);
|
||||
SetList(applications);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user