mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-31 06:25:20 +00:00
[Run] Fix exception (#9068)
This commit is contained in:
@@ -349,7 +349,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
Win32Program olditem = new Win32Program
|
||||
{
|
||||
Name = "oldpath",
|
||||
ExecutableName = path,
|
||||
ExecutableName = oldpath,
|
||||
FullPath = fullPath,
|
||||
};
|
||||
|
||||
|
@@ -100,7 +100,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||
|
||||
string extension = Path.GetExtension(newPath);
|
||||
Win32Program.ApplicationType appType = Win32Program.GetAppTypeFromPath(newPath);
|
||||
Programs.Win32Program newApp = Programs.Win32Program.GetAppFromPath(newPath);
|
||||
Programs.Win32Program newApp = Win32Program.GetAppFromPath(newPath);
|
||||
Programs.Win32Program oldApp = null;
|
||||
|
||||
// Once the shortcut application is renamed, the old app does not exist and therefore when we try to get the FullPath we get the lnk path instead of the exe path
|
||||
@@ -111,7 +111,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||
{
|
||||
if (appType == Win32Program.ApplicationType.ShortcutApplication)
|
||||
{
|
||||
oldApp = new Win32Program() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = newApp.ExecutableName, FullPath = newApp.FullPath };
|
||||
oldApp = new Win32Program() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = Path.GetFileName(e.OldName), FullPath = newApp.FullPath };
|
||||
}
|
||||
else if (appType == Win32Program.ApplicationType.InternetShortcutApplication)
|
||||
{
|
||||
@@ -124,13 +124,20 @@ namespace Microsoft.Plugin.Program.Storage
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Exception($"OnAppRenamed-{extension}Program|{oldPath}|Unable to create program from {oldPath}", ex, GetType());
|
||||
Log.Exception($"OnAppRenamed-{extension} Program|{e.OldName}|Unable to create program from {oldPath}", ex, GetType());
|
||||
}
|
||||
|
||||
// To remove the old app which has been renamed and to add the new application.
|
||||
if (oldApp != null)
|
||||
{
|
||||
Remove(oldApp);
|
||||
if (string.IsNullOrWhiteSpace(oldApp.Name) || string.IsNullOrWhiteSpace(oldApp.ExecutableName) || string.IsNullOrWhiteSpace(oldApp.FullPath))
|
||||
{
|
||||
Log.Error($"Old app was not initialized properly. OldFullPath: {e.OldFullPath}; OldName: {e.OldName}; FullPath: {e.FullPath}", GetType());
|
||||
}
|
||||
else
|
||||
{
|
||||
Remove(oldApp);
|
||||
}
|
||||
}
|
||||
|
||||
if (newApp != null)
|
||||
|
Reference in New Issue
Block a user