Functionality to detect Win32 apps which are installed, deleted or renamed while PowerToys is running (#4960)

* Added file system wrapper and interface

* added win32program repository which would load store app and also handle new apps being added/deleted

* Added event handlers to win32 program repo

* added paths to monitor and setting FSWs for each location

* Events firing as expected

* filter extensions added, events fire as expected

* override gethashcode so that duplicates don't show up. OnCreated and OnDeleted events trigger as expected

* implemented setter for filters in FileSystemWatcher

* Rename adds item but does not seem to delete the previous app

* catching an exception when a duplicate item is inserted

* Removed notify filter for directory because we only need to monitor files

* Added exe programs to be indexed in the desktop and startmenu

* created a new class to init FileSystemHelpers instead of main

* Added fix for shortcut applications to work as expected while renaming and deleting them

* Added wrappers for file system operations

* Added some tests

* Added all tests for appref-ms and added a condition to search in sub directories

* Added tests for Exe applications

* Added lnk app tests

* Added tests for shortcut applications

* removed unnecessary wrappers

* override Equals for win32

* removed debug statements

* Fixed exe issue

* Fixed internet shortcut exception

* fixed renaming shortcut apps

* Added a retry block for ReadAllLines

* capitalized method name - RetrieveTargetPath

* made naming consistent, helper variables start with underscore

* Added the exception condition back

* renamed Win32ProgramRepositoryHelper to Win32ProgramFileSystemWatchers

* made win32Program repository variable static

* changed list to ilist

* disposed file system watchers

* make retrieveTargetPath upper case in tests
This commit is contained in:
Alekhya
2020-07-17 22:32:21 -07:00
committed by GitHub
parent 034079b441
commit d09253e532
17 changed files with 894 additions and 58 deletions

View File

@@ -48,7 +48,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
internal static void LoadAllApplications(this List<ProgramSource> list)
{
Main._win32s
/*Main._win32s
.Where(t1 => !ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier))
.ToList()
.ForEach(t1 => ProgramSetting.ProgramSettingDisplayList
@@ -60,7 +60,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
UniqueIdentifier = t1.UniqueIdentifier,
Enabled = t1.Enabled
}
));
));*/
}
internal static void SetProgramSourcesStatus(this List<ProgramSource> list, List<ProgramSource> selectedProgramSourcesToDisable, bool status)
@@ -70,10 +70,10 @@ namespace Microsoft.Plugin.Program.Views.Commands
.ToList()
.ForEach(t1 => t1.Enabled = status);
Main._win32s
/*Main._win32s
.Where(t1 => selectedProgramSourcesToDisable.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && t1.Enabled != status))
.ToList()
.ForEach(t1 => t1.Enabled = status);
.ForEach(t1 => t1.Enabled = status);*/
}
internal static void StoreDisabledInSettings(this List<ProgramSource> list)
@@ -114,8 +114,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
internal static bool IsReindexRequired(this List<ProgramSource> selectedItems)
{
if (selectedItems.Where(t1 => t1.Enabled).Count() > 0
&& selectedItems.Where(t1 => t1.Enabled && !Main._win32s.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Count() > 0)
if (selectedItems.Where(t1 => t1.Enabled).Count() > 0)
return true;
// ProgramSources holds list of user added directories,