@@ -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 ;
0 commit comments