Fix for internet shortcut app not showing up on installation (#5131)

* added changed for internet shortcut app

* Added AppChanged event for url files

* Tests added

* refactoring
This commit is contained in:
Alekhya
2020-07-22 10:58:01 -07:00
committed by GitHub
parent f7ad935dfb
commit b59ec5e78b
4 changed files with 82 additions and 29 deletions

View File

@@ -39,7 +39,7 @@ namespace Microsoft.Plugin.Program.Storage
_fileSystemWatcherHelpers[index].Path = _pathsToWatch[index];
// to be notified when there is a change to a file
_fileSystemWatcherHelpers[index].NotifyFilter = NotifyFilters.FileName;
_fileSystemWatcherHelpers[index].NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
// filtering the app types that we want to monitor
_fileSystemWatcherHelpers[index].Filters = extensionsToWatch;
@@ -48,6 +48,7 @@ namespace Microsoft.Plugin.Program.Storage
_fileSystemWatcherHelpers[index].Created += OnAppCreated;
_fileSystemWatcherHelpers[index].Deleted += OnAppDeleted;
_fileSystemWatcherHelpers[index].Renamed += OnAppRenamed;
_fileSystemWatcherHelpers[index].Changed += OnAppChanged;
// Enable the file system watcher
_fileSystemWatcherHelpers[index].EnableRaisingEvents = true;
@@ -166,10 +167,26 @@ namespace Microsoft.Plugin.Program.Storage
private void OnAppCreated(object sender, FileSystemEventArgs e)
{
string path = e.FullPath;
Programs.Win32 app = Programs.Win32.GetAppFromPath(path);
if (app != null)
if(!Path.GetExtension(path).Equals(urlExtension))
{
Add(app);
Programs.Win32 app = Programs.Win32.GetAppFromPath(path);
if (app != null)
{
Add(app);
}
}
}
private void OnAppChanged(object sender, FileSystemEventArgs e)
{
string path = e.FullPath;
if (Path.GetExtension(path).Equals(urlExtension))
{
Programs.Win32 app = Programs.Win32.GetAppFromPath(path);
if (app != null)
{
Add(app);
}
}
}