mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
Fix for File Not Found exception while indexing invalid Package App (#4971)
* Catching file not found exception * removed unnecessary header files * Added a string.empty check for installed location * reusing package wrapper instead of package installing event args
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
using Package = Windows.ApplicationModel.Package;
|
||||
using Microsoft.Plugin.Program.Logger;
|
||||
using System.IO;
|
||||
using Package = Windows.ApplicationModel.Package;
|
||||
|
||||
namespace Microsoft.Plugin.Program.Programs
|
||||
{
|
||||
public class PackageWrapper : IPackage
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Name { get; } = string.Empty;
|
||||
|
||||
public string FullName { get; }
|
||||
public string FullName { get; } = string.Empty;
|
||||
|
||||
public string FamilyName { get; }
|
||||
public string FamilyName { get; } = string.Empty;
|
||||
|
||||
public bool IsFramework { get; }
|
||||
public bool IsFramework { get; } = false;
|
||||
|
||||
public bool IsDevelopmentMode { get; }
|
||||
public bool IsDevelopmentMode { get; } = false;
|
||||
|
||||
public string InstalledLocation { get; }
|
||||
public string InstalledLocation { get; } = string.Empty;
|
||||
|
||||
public PackageWrapper() { }
|
||||
|
||||
public PackageWrapper(string Name, string FullName, string FamilyName, bool IsFramework, bool IsDevelopmentMode, string InstalledLocation)
|
||||
{
|
||||
@@ -28,7 +32,9 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
|
||||
public static PackageWrapper GetWrapperFromPackage(Package package)
|
||||
{
|
||||
return new PackageWrapper(
|
||||
try
|
||||
{
|
||||
return new PackageWrapper(
|
||||
package.Id.Name,
|
||||
package.Id.FullName,
|
||||
package.Id.FamilyName,
|
||||
@@ -36,6 +42,12 @@ namespace Microsoft.Plugin.Program.Programs
|
||||
package.IsDevelopmentMode,
|
||||
package.InstalledLocation.Path
|
||||
);
|
||||
}
|
||||
catch(FileNotFoundException ex)
|
||||
{
|
||||
ProgramLogger.LogException($"PackageWrapper", "GetWrapperFromPackage","package.InstalledLocation.Path",$"File Not Found for package {package.Id.Name}", ex);
|
||||
return new PackageWrapper();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user