mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Add more error handling, fix #1252
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Shell;
|
using Shell;
|
||||||
@@ -205,9 +206,17 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
if (Directory.Exists(directory))
|
if (Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
var files = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories).Where(
|
IEnumerable<string> files;
|
||||||
f => suffixes.Contains(Extension(f))
|
try
|
||||||
);
|
{
|
||||||
|
files = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories);
|
||||||
|
}
|
||||||
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Log.Exception($"|Program.Win32.ProgramPaths|Can't parse directory <{directory}>", e);
|
||||||
|
return new string[] { };
|
||||||
|
}
|
||||||
|
files = files.Where(f => suffixes.Contains(Extension(f)));
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -308,10 +317,21 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
entry.ExecutableName = subkey;
|
entry.ExecutableName = subkey;
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Win32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Win32();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Win32();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new Win32();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//private static Win32 ScoreFilter(Win32 p)
|
//private static Win32 ScoreFilter(Win32 p)
|
||||||
|
|||||||
Reference in New Issue
Block a user