File tree Expand file tree Collapse file tree
WheelWizard.Test/Features/Settings Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using WheelWizard . Services ;
2+
3+ namespace WheelWizard . Test . Features . Settings ;
4+
5+ [ Collection ( "SettingsFeature" ) ]
6+ public class PathManagerTests
7+ {
8+ [ Fact ]
9+ public void TrySetWheelWizardAppdataPath_ReturnsFalse_WhenTargetPathIsUnavailable ( )
10+ {
11+ if ( ! OperatingSystem . IsWindows ( ) )
12+ return ;
13+
14+ var unavailablePath = GetUnavailableWindowsPath ( ) ;
15+ var result = PathManager . TrySetWheelWizardAppdataPath ( unavailablePath , out var errorMessage , out _ ) ;
16+
17+ Assert . False ( result ) ;
18+ Assert . False ( string . IsNullOrWhiteSpace ( errorMessage ) ) ;
19+ }
20+
21+ private static string GetUnavailableWindowsPath ( )
22+ {
23+ return $@ "\\nonexistent-host\WheelWizardTests\{ Guid . NewGuid ( ) : N} ";
24+ }
25+ }
Original file line number Diff line number Diff line change @@ -95,14 +95,35 @@ public static bool IsUsingCustomWheelWizardAppdataPath
9595 return null ;
9696
9797 var normalized = FileHelper . NormalizePath ( storedPath ) ;
98- return FileHelper . PathsEqual ( normalized , DefaultWheelWizardAppdataPath ) ? null : normalized ;
98+ if ( FileHelper . PathsEqual ( normalized , DefaultWheelWizardAppdataPath ) )
99+ return null ;
100+
101+ // If a previously selected custom location is no longer available (for example,
102+ // when an external drive letter changes), fall back to the default path.
103+ if ( ! TryEnsureWheelWizardAppdataPathAccessible ( normalized ) )
104+ return null ;
105+
106+ return normalized ;
99107 }
100108 catch
101109 {
102110 return null ;
103111 }
104112 }
105113
114+ private static bool TryEnsureWheelWizardAppdataPathAccessible ( string normalizedPath )
115+ {
116+ try
117+ {
118+ FileHelper . EnsureDirectory ( normalizedPath ) ;
119+ return true ;
120+ }
121+ catch
122+ {
123+ return false ;
124+ }
125+ }
126+
106127 private static string ? LoadPersistedWheelWizardAppdataOverride ( )
107128 {
108129#if WINDOWS
You can’t perform that action at this time.
0 commit comments