Skip to content

Commit 28b4f0e

Browse files
committed
Prevent failing to load desktop shortcuts from breaking package operations (fix #4328)
1 parent 0e49a53 commit 28b4f0e

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
66
<!-- IF BUILD FAILS DUE TO MISSING Microsoft.Management.Deployment NAMESPACE,
77
TOGGLE THE LAST NUMBER OF THE LINE BELOW 1 UNIT UP OR DOWN, AND REBUILD-->
8-
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
8+
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>
99

1010
<SdkVersion>8.0.407</SdkVersion>
1111
<Authors>Martí Climent and the contributors</Authors>

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Classes/DesktopShortcutsDatabase.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,21 @@ public static Status GetStatus(string shortcutPath)
103103
/// <returns>A list of desktop shortcut paths</returns>
104104
public static List<string> GetShortcutsOnDisk()
105105
{
106-
List<string> shortcuts = [];
107-
string UserDesktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
108-
string CommonDesktop = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
109-
shortcuts.AddRange(Directory.EnumerateFiles(UserDesktop, "*.lnk"));
110-
shortcuts.AddRange(Directory.EnumerateFiles(CommonDesktop, "*.lnk"));
111-
return shortcuts;
106+
try
107+
{
108+
List<string> shortcuts = [];
109+
string UserDesktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
110+
string CommonDesktop = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
111+
if (UserDesktop != "") shortcuts.AddRange(Directory.EnumerateFiles(UserDesktop, "*.lnk"));
112+
if (CommonDesktop != "") shortcuts.AddRange(Directory.EnumerateFiles(CommonDesktop, "*.lnk"));
113+
return shortcuts;
114+
}
115+
catch (Exception ex)
116+
{
117+
Logger.Error("Failed to load desktop shortcuts on disk");
118+
Logger.Error(ex);
119+
return [];
120+
}
112121
}
113122

114123
/// <summary>

0 commit comments

Comments
 (0)