mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-06 03:07:54 +08:00
disable file watcher
Filewatcher will only watch directory given by user, a bit useless. disable for now
This commit is contained in:
parent
ee542f0fec
commit
eb74414b16
@ -2,57 +2,57 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Wox.Plugin.Program.ProgramSources;
|
using Wox.Plugin.Program.Programs;
|
||||||
|
|
||||||
namespace Wox.Plugin.Program
|
namespace Wox.Plugin.Program
|
||||||
{
|
{
|
||||||
internal static class FileChangeWatcher
|
//internal static class FileChangeWatcher
|
||||||
{
|
//{
|
||||||
private static readonly List<string> WatchedPath = new List<string>();
|
// private static readonly List<string> WatchedPath = new List<string>();
|
||||||
// todo remove previous watcher events
|
// // todo remove previous watcher events
|
||||||
public static void AddAll(List<UnregisteredPrograms> sources, string[] suffixes)
|
// public static void AddAll(List<UnregisteredPrograms> sources, string[] suffixes)
|
||||||
{
|
// {
|
||||||
foreach (var s in sources)
|
// foreach (var s in sources)
|
||||||
{
|
// {
|
||||||
if (Directory.Exists(s.Location))
|
// if (Directory.Exists(s.Location))
|
||||||
{
|
// {
|
||||||
AddWatch(s.Location, suffixes);
|
// AddWatch(s.Location, suffixes);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static void AddWatch(string path, string[] programSuffixes, bool includingSubDirectory = true)
|
// public static void AddWatch(string path, string[] programSuffixes, bool includingSubDirectory = true)
|
||||||
{
|
// {
|
||||||
if (WatchedPath.Contains(path)) return;
|
// if (WatchedPath.Contains(path)) return;
|
||||||
if (!Directory.Exists(path))
|
// if (!Directory.Exists(path))
|
||||||
{
|
// {
|
||||||
Log.Warn($"FileChangeWatcher: {path} doesn't exist");
|
// Log.Warn($"FileChangeWatcher: {path} doesn't exist");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
WatchedPath.Add(path);
|
// WatchedPath.Add(path);
|
||||||
foreach (string fileType in programSuffixes)
|
// foreach (string fileType in programSuffixes)
|
||||||
{
|
// {
|
||||||
FileSystemWatcher watcher = new FileSystemWatcher
|
// FileSystemWatcher watcher = new FileSystemWatcher
|
||||||
{
|
// {
|
||||||
Path = path,
|
// Path = path,
|
||||||
IncludeSubdirectories = includingSubDirectory,
|
// IncludeSubdirectories = includingSubDirectory,
|
||||||
Filter = $"*.{fileType}",
|
// Filter = $"*.{fileType}",
|
||||||
EnableRaisingEvents = true
|
// EnableRaisingEvents = true
|
||||||
};
|
// };
|
||||||
watcher.Changed += FileChanged;
|
// watcher.Changed += FileChanged;
|
||||||
watcher.Created += FileChanged;
|
// watcher.Created += FileChanged;
|
||||||
watcher.Deleted += FileChanged;
|
// watcher.Deleted += FileChanged;
|
||||||
watcher.Renamed += FileChanged;
|
// watcher.Renamed += FileChanged;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void FileChanged(object source, FileSystemEventArgs e)
|
// private static void FileChanged(object source, FileSystemEventArgs e)
|
||||||
{
|
// {
|
||||||
Task.Run(() =>
|
// Task.Run(() =>
|
||||||
{
|
// {
|
||||||
Main.IndexPrograms();
|
// Main.IndexPrograms();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user