Fix the problem which Powertoys Run shows duplicated applications. (#37924)

init

Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
This commit is contained in:
moooyo
2025-03-14 10:33:15 +08:00
committed by GitHub
parent 924898ae94
commit 39073f0467
2 changed files with 7 additions and 6 deletions

View File

@@ -96,6 +96,12 @@ namespace Microsoft.Plugin.Program.Storage
string oldPath = e.OldFullPath;
string newPath = e.FullPath;
// fix for https://github.com/microsoft/PowerToys/issues/34391
// the msi installer creates a shortcut, which is detected by the PT Run and ends up in calling this OnAppRenamed method
// the thread needs to be halted for a short time to avoid locking the new shortcut file as we read it, otherwise the lock causes
// in the issue scenario that a warning is popping up during the msi install process.
System.Threading.Thread.Sleep(1000);
string extension = Path.GetExtension(newPath);
Win32Program.ApplicationType oldAppType = Win32Program.GetAppTypeFromPath(oldPath);
Programs.Win32Program newApp = Win32Program.GetAppFromPath(newPath);

View File

@@ -136,14 +136,9 @@ namespace Wox.Infrastructure
var link = new ShellLink();
const int STGM_READ = 0;
// Make sure not to open exclusive handles.
// See: https://github.com/microsoft/WSL/issues/11276
const int STGM_SHARE_DENY_NONE = 0x00000040;
const int STGM_TRANSACTED = 0x00010000;
try
{
((IPersistFile)link).Load(path, STGM_READ | STGM_SHARE_DENY_NONE | STGM_TRANSACTED);
((IPersistFile)link).Load(path, STGM_READ);
}
catch (System.IO.FileNotFoundException ex)
{