Skip to content

Commit 8c8c70e

Browse files
Address review comments
1 parent 950c506 commit 8c8c70e

File tree

8 files changed

+200
-197
lines changed

8 files changed

+200
-197
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 & 14 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;
@@ -88,21 +89,28 @@ public static string GetPathForDisplay(string path, bool substituteEnvironmentVa
8889
string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
8990
string tempPath = Path.GetTempPath().TrimEnd(Path.DirectorySeparatorChar);
9091

91-
path = Path.GetFullPath(path);
92-
93-
if (path.StartsWith(tempPath, StringComparison.OrdinalIgnoreCase) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
92+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
9493
{
95-
return path.Replace(tempPath, TempEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
96-
}
97-
else if (path.StartsWith(localAppDataPath, StringComparison.OrdinalIgnoreCase) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
98-
{
99-
return path.Replace(localAppDataPath, LocalAppDataEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
94+
if (path.StartsWith(tempPath, StringComparison.OrdinalIgnoreCase))
95+
{
96+
return path.Replace(tempPath, TempEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
97+
}
98+
else if (path.StartsWith(localAppDataPath, StringComparison.OrdinalIgnoreCase))
99+
{
100+
return path.Replace(localAppDataPath, LocalAppDataEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
101+
}
102+
else if (path.StartsWith(userProfilePath, StringComparison.OrdinalIgnoreCase))
103+
{
104+
return path.Replace(userProfilePath, UserProfileEnvironmentVariable, StringComparison.OrdinalIgnoreCase);
105+
}
100106
}
101-
else if (path.StartsWith(userProfilePath, StringComparison.OrdinalIgnoreCase) && !path.StartsWith(localAppDataPath, StringComparison.OrdinalIgnoreCase))
107+
else
102108
{
103-
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
104-
? path.Replace(userProfilePath, UserProfileEnvironmentVariable, StringComparison.OrdinalIgnoreCase)
105-
: path.Replace(userProfilePath, UserHomeDirectoryShortcutUnix, StringComparison.OrdinalIgnoreCase);
109+
// Paths are case-sensitive on Unix
110+
if (path.StartsWith(userProfilePath, StringComparison.Ordinal))
111+
{
112+
return path.Replace(userProfilePath, UserHomeDirectoryShortcutUnix, StringComparison.Ordinal);
113+
}
106114
}
107115

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

0 commit comments

Comments
 (0)