mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix Wox handled exception at launch #221
This commit is contained in:
parent
57bc1f2032
commit
c20314f83c
2 changed files with 23 additions and 8 deletions
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
|
|
@ -24,7 +25,7 @@ namespace Wox.Infrastructure.Storage
|
|||
{
|
||||
try
|
||||
{
|
||||
FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
FileStream fileStream = new FileStream(ConfigPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
serializedObject = binaryFormatter.Deserialize(fileStream) as T;
|
||||
fileStream.Close();
|
||||
|
|
@ -37,10 +38,22 @@ namespace Wox.Infrastructure.Storage
|
|||
|
||||
protected override void SaveInternal()
|
||||
{
|
||||
FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
binaryFormatter.Serialize(fileStream, serializedObject);
|
||||
fileStream.Close();
|
||||
try
|
||||
{
|
||||
FileStream fileStream = new FileStream(ConfigPath, FileMode.Create);
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
binaryFormatter.Serialize(fileStream, serializedObject);
|
||||
fileStream.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace Wox.Plugin.SystemPlugins.Program
|
|||
public class Programs : BaseSystemPlugin, ISettingProvider
|
||||
{
|
||||
private static object lockObject = new object();
|
||||
private static List<Program> programs = new List<Program>();
|
||||
private static List<IProgramSource> sources = new List<IProgramSource>();
|
||||
private static Dictionary<string, Type> SourceTypes = new Dictionary<string, Type>() {
|
||||
{"FileSystemProgramSource", typeof(FileSystemProgramSource)},
|
||||
|
|
@ -29,7 +30,7 @@ namespace Wox.Plugin.SystemPlugins.Program
|
|||
if (query.RawQuery.Trim().Length <= 1) return new List<Result>();
|
||||
|
||||
var fuzzyMather = FuzzyMatcher.Create(query.RawQuery);
|
||||
List<Program> returnList = ProgramCacheStorage.Instance.Programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||
returnList.ForEach(ScoreFilter);
|
||||
returnList = returnList.OrderByDescending(o => o.Score).ToList();
|
||||
|
||||
|
|
@ -75,6 +76,7 @@ namespace Wox.Plugin.SystemPlugins.Program
|
|||
protected override void InitInternal(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
programs = ProgramCacheStorage.Instance.Programs;
|
||||
using (new Timeit("Program Index"))
|
||||
{
|
||||
IndexPrograms();
|
||||
|
|
@ -121,10 +123,10 @@ namespace Wox.Plugin.SystemPlugins.Program
|
|||
}
|
||||
|
||||
// filter duplicate program
|
||||
tempPrograms = tempPrograms.GroupBy(x => new { x.ExecutePath, x.ExecuteName })
|
||||
programs = tempPrograms.GroupBy(x => new { x.ExecutePath, x.ExecuteName })
|
||||
.Select(g => g.First()).ToList();
|
||||
|
||||
ProgramCacheStorage.Instance.Programs = tempPrograms;
|
||||
ProgramCacheStorage.Instance.Programs = programs;
|
||||
ProgramCacheStorage.Instance.Save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue