Skip to content

Commit f283ecf

Browse files
Address review comments
1 parent 950c506 commit f283ecf

File tree

8 files changed

+241
-236
lines changed

8 files changed

+241
-236
lines changed

.gitmodules

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[submodule "src/WingetCreateCore/Common/Msi/rust-msi"]
2-
path = src/WingetCreateCore/Common/Msi/rust-msi\
2+
path = src/WingetCreateCore/Common/Msi/rust-msi
33
# TODO: Switch to mdsteele/rust-msi once the PR is merged
44
# https://github.com/mdsteele/rust-msi/pull/18
5-
url = https://github.com/vedantmgoyal9/rust-msi
5+
url = https://github.com/vedantmgoyal9/rust-msi
66
shallow = true
7+
branch = master

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ The latest version of the standalone exe can be found at https://aka.ms/wingetcr
7575

7676
```yaml
7777
- task: UseDotNet@2
78-
displayName: 'Install .NET Runtime'
78+
displayName: "Install .NET Runtime"
7979
inputs:
8080
packageType: sdk
81-
version: '8.x'
81+
version: "8.x"
8282
installationPath: '$(ProgramFiles)\dotnet'
8383
```
8484

src/WingetCreateCLI/Commands/SettingsCommand.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,32 @@ private static bool OpenJsonFile(string path)
9191
return false;
9292
}
9393

94-
try
94+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
9595
{
96-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
96+
try
9797
{
9898
Process.Start(new ProcessStartInfo { UseShellExecute = true, FileName = path });
9999
}
100-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
101-
{
102-
Process.Start("xdg-open", path);
103-
}
104-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
100+
catch (Win32Exception e)
105101
{
106-
Process.Start("open", path);
102+
Logger.ErrorLocalized(nameof(Resources.Error_Prefix), e.Message);
103+
return false;
107104
}
108-
else
109-
{
110-
throw new PlatformNotSupportedException();
111-
}
112-
113-
return true;
114105
}
115-
catch (Win32Exception e)
106+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
116107
{
117-
Logger.ErrorLocalized(nameof(Resources.Error_Prefix), e.Message);
118-
return false;
108+
Process.Start("xdg-open", path);
109+
}
110+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
111+
{
112+
Process.Start("open", path);
119113
}
114+
else
115+
{
116+
throw new PlatformNotSupportedException();
117+
}
118+
119+
return true;
120120
}
121121
}
122122
}

src/WingetCreateCLI/Common.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ public static class Common
2323

2424
private static readonly Lazy<string> AppStatePathLazy = new(() =>
2525
{
26-
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".wingetcreate");
2726
#if WINDOWS
28-
path = IsRunningAsUwp()
27+
string path = IsRunningAsUwp()
2928
? ApplicationData.Current.LocalFolder.Path
3029
: Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", ModuleName);
30+
#else
31+
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".wingetcreate");
3132
#endif
3233
Directory.CreateDirectory(path);
3334
return path;
@@ -90,19 +91,28 @@ public static string GetPathForDisplay(string path, bool substituteEnvironmentVa
9091

9192
path = Path.GetFullPath(path);
9293

93-
if (path.StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
94-
{
95-
return path.Replace(tempPath, TempEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
96-
}
97-
else if (path.StartsWith(localAppDataPath, StringComparison.OrdinalIgnoreCase) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
94+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
9895
{
99-
return path.Replace(localAppDataPath, LocalAppDataEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
96+
if (path.StartsWith(tempPath, StringComparison.OrdinalIgnoreCase))
97+
{
98+
return path.Replace(tempPath, TempEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
99+
}
100+
else if (path.StartsWith(localAppDataPath, StringComparison.OrdinalIgnoreCase))
101+
{
102+
return path.Replace(localAppDataPath, LocalAppDataEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
103+
}
104+
else if (path.StartsWith(userProfilePath, StringComparison.OrdinalIgnoreCase))
105+
{
106+
return path.Replace(userProfilePath, UserProfileEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
107+
}
100108
}
101-
else if (path.StartsWith(userProfilePath, StringComparison.OrdinalIgnoreCase) && !path.StartsWith(localAppDataPath, StringComparison.OrdinalIgnoreCase))
109+
else
102110
{
103-
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
104-
? path.Replace(userProfilePath, UserProfileEnvironmentVariable, StringComparison.OrdinalIgnoreCase)
105-
: path.Replace(userProfilePath, UserHomeDirectoryShortcutUnix, StringComparison.OrdinalIgnoreCase);
111+
// Paths are case-sensitive on Unix
112+
if (path.StartsWith(userProfilePath, StringComparison.Ordinal))
113+
{
114+
return path.Replace(userProfilePath, UserHomeDirectoryShortcutUnix, StringComparison.Ordinal);
115+
}
106116
}
107117

108118
return path;
Submodule rust-msi added at 0dde366

0 commit comments

Comments
 (0)