Skip to content

Commit f092ea5

Browse files
committed
Fixes for app data folder consistently using aumid instead of appid
1 parent 288e76b commit f092ea5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Microsoft.Toolkit.Uwp.Notifications/Toasts/Compat/Desktop/Win32AppInfo.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ public static Win32AppInfo Get()
9292
if (IsAlphaBitmap(bmp, out var bmpData))
9393
{
9494
var alphaBitmap = GetAlphaBitmapFromBitmapData(bmpData);
95-
iconPath = SaveIconToAppPath(alphaBitmap, appId);
95+
iconPath = SaveIconToAppPath(alphaBitmap, aumid);
9696
}
9797
else
9898
{
99-
iconPath = SaveIconToAppPath(bmp, appId);
99+
iconPath = SaveIconToAppPath(bmp, aumid);
100100
}
101101
}
102102
catch
@@ -122,7 +122,7 @@ public static Win32AppInfo Get()
122122
if (string.IsNullOrWhiteSpace(iconPath))
123123
{
124124
// We use the one from the process
125-
iconPath = ExtractAndObtainIconFromCurrentProcess(process, appId);
125+
iconPath = ExtractAndObtainIconFromCurrentProcess(process, aumid);
126126
}
127127

128128
return new Win32AppInfo()
@@ -155,12 +155,12 @@ private static string GetDisplayNameFromCurrentProcess(Process process)
155155
return process.ProcessName;
156156
}
157157

158-
private static string ExtractAndObtainIconFromCurrentProcess(Process process, string appId)
158+
private static string ExtractAndObtainIconFromCurrentProcess(Process process, string aumid)
159159
{
160-
return ExtractAndObtainIconFromPath(process.MainModule.FileName, appId);
160+
return ExtractAndObtainIconFromPath(process.MainModule.FileName, aumid);
161161
}
162162

163-
private static string ExtractAndObtainIconFromPath(string pathToExtract, string appId)
163+
private static string ExtractAndObtainIconFromPath(string pathToExtract, string aumid)
164164
{
165165
try
166166
{
@@ -169,7 +169,7 @@ private static string ExtractAndObtainIconFromPath(string pathToExtract, string
169169

170170
using (var bmp = icon.ToBitmap())
171171
{
172-
return SaveIconToAppPath(bmp, appId);
172+
return SaveIconToAppPath(bmp, aumid);
173173
}
174174
}
175175
catch
@@ -178,11 +178,11 @@ private static string ExtractAndObtainIconFromPath(string pathToExtract, string
178178
}
179179
}
180180

181-
private static string SaveIconToAppPath(Bitmap bitmap, string appId)
181+
private static string SaveIconToAppPath(Bitmap bitmap, string aumid)
182182
{
183183
try
184184
{
185-
var path = Path.Combine(GetAppDataFolderPath(appId), "Icon.png");
185+
var path = Path.Combine(GetAppDataFolderPath(aumid), "Icon.png");
186186

187187
// Ensure the directories exist
188188
Directory.CreateDirectory(Path.GetDirectoryName(path));
@@ -201,9 +201,9 @@ private static string SaveIconToAppPath(Bitmap bitmap, string appId)
201201
/// Gets the app data folder path within the ToastNotificationManagerCompat folder, used for storing icon assets and any additional data.
202202
/// </summary>
203203
/// <returns>Returns a string of the absolute folder path.</returns>
204-
public static string GetAppDataFolderPath(string appId)
204+
public static string GetAppDataFolderPath(string aumid)
205205
{
206-
string conciseAumid = appId.Contains("\\") ? GenerateGuid(appId) : appId;
206+
string conciseAumid = aumid.Contains('\\') || aumid.Contains('/') ? GenerateGuid(aumid) : aumid;
207207

208208
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "ToastNotificationManagerCompat", "Apps", conciseAumid);
209209
}

0 commit comments

Comments
 (0)