Skip to content

Commit

Permalink
Better handle missing icons and executables in ScoopFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
Klocman committed Jul 3, 2023
1 parent 32ca90f commit 7d0a722
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions source/UninstallTools/Factory/ScoopFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,19 @@ private sealed class AppManifestArchitecture
var shortcuts = manifest.Architecture?[install.Architecture]?.Shortcuts ?? manifest.Shortcuts;
if (shortcuts != null)
{
executables.AddRange(
shortcuts.Select(x => Path.Combine(currentDir, x[0])));
executables.AddRange(shortcuts.Select(x => Path.Combine(currentDir, x[0])));

var icons = shortcuts
.Where(x => x.Length >= 4 && x[3].EndsWith(".ico"))
.Select(x => Path.Combine(currentDir, x[3]));
if (icons.Any())
try
{
try
{
entry.IconBitmap = new Icon(icons.First());
}
catch { }
var icon = shortcuts.Where(x => x.Length >= 4 && x[3].EndsWith(".ico"))
.Select(x => Path.Combine(currentDir, x[3]))
.FirstOrDefault(File.Exists);
if (icon != null)
entry.IconBitmap = new Icon(icon);
}
catch (Exception ex)
{
Console.WriteLine($@"Failed to get icon for {name} - {ex}");
}
}

Expand All @@ -271,11 +271,12 @@ private sealed class AppManifestArchitecture

if (executables.Any())
{
entry.SortedExecutables = AppExecutablesSearcher.SortListExecutables(
executables.Distinct().Select(x => new FileInfo(x)),
entry.DisplayNameTrimmed)
.Select(x => x.FullName)
.ToArray();
entry.SortedExecutables = AppExecutablesSearcher.SortListExecutables(executables.Distinct()
.Where(File.Exists)
.Select(x => new FileInfo(x)),
entry.DisplayNameTrimmed)
.Select(x => x.FullName)
.ToArray();
}
else
{
Expand Down

0 comments on commit 7d0a722

Please sign in to comment.