mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
fix #185. Loading index cache on startup.
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Wox.Plugin.SystemPlugins.Program
|
||||
int BonusPoints { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class AbstractProgramSource : IProgramSource
|
||||
{
|
||||
public abstract List<Program> LoadPrograms();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using Wox.Infrastructure;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.Program
|
||||
{
|
||||
[Serializable]
|
||||
public class Program
|
||||
{
|
||||
private static readonly global::System.Text.RegularExpressions.Regex AbbrRegexp = new global::System.Text.RegularExpressions.Regex("[^A-Z0-9]", global::System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||
|
||||
18
Wox.Plugin.SystemPlugins/Program/ProgramCacheStorage.cs
Normal file
18
Wox.Plugin.SystemPlugins/Program/ProgramCacheStorage.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.Program
|
||||
{
|
||||
[Serializable]
|
||||
public class ProgramCacheStorage : BinaryStorage<ProgramCacheStorage>
|
||||
{
|
||||
public List<Program> Programs = new List<Program>();
|
||||
|
||||
protected override string ConfigName
|
||||
{
|
||||
get { return "ProgramIndexCache"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
public class AppPathsProgramSource: AbstractProgramSource
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
public class CommonStartMenuProgramSource : FileSystemProgramSource
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ using Log = Wox.Infrastructure.Logger.Log;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
public class FileSystemProgramSource : AbstractProgramSource
|
||||
{
|
||||
private string baseDirectory;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
namespace Wox.Plugin.SystemPlugins.Program.ProgramSources
|
||||
{
|
||||
[Serializable]
|
||||
[global::System.ComponentModel.Browsable(false)]
|
||||
public class UserStartMenuProgramSource : FileSystemProgramSource
|
||||
{
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Windows.Forms;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin.SystemPlugins.Program.ProgramSources;
|
||||
@@ -73,6 +77,10 @@ namespace Wox.Plugin.SystemPlugins.Program
|
||||
protected override void InitInternal(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
using (new Timeit("Loading Program Index Cache"))
|
||||
{
|
||||
programs = ProgramCacheStorage.Instance.Programs;
|
||||
}
|
||||
IndexPrograms();
|
||||
}
|
||||
|
||||
@@ -82,6 +90,7 @@ namespace Wox.Plugin.SystemPlugins.Program
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
|
||||
initing = true;
|
||||
|
||||
List<ProgramSource> programSources = new List<ProgramSource>();
|
||||
@@ -125,6 +134,9 @@ namespace Wox.Plugin.SystemPlugins.Program
|
||||
|
||||
programs = tempPrograms;
|
||||
initing = false;
|
||||
|
||||
ProgramCacheStorage.Instance.Programs = programs;
|
||||
ProgramCacheStorage.Instance.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user