@@ -31,11 +31,12 @@ namespace Flow.Launcher.Infrastructure.Storage
3131 protected JsonStorage ( )
3232 {
3333 }
34+
3435 public JsonStorage ( string filePath )
3536 {
3637 FilePath = filePath ;
3738 DirectoryPath = Path . GetDirectoryName ( filePath ) ?? throw new ArgumentException ( "Invalid file path" ) ;
38-
39+
3940 Helper . ValidateDirectory ( DirectoryPath ) ;
4041 }
4142
@@ -97,6 +98,7 @@ private async ValueTask<T> LoadBackupOrDefaultAsync()
9798 return default ;
9899 }
99100 }
101+
100102 private void RestoreBackup ( )
101103 {
102104 Log . Info ( $ "|JsonStorage.Load|Failed to load settings.json, { BackupFilePath } restored successfully") ;
@@ -179,25 +181,21 @@ private void BackupOriginFile()
179181 public void Save ( )
180182 {
181183 string serialized = JsonSerializer . Serialize ( Data ,
182- new JsonSerializerOptions
183- {
184- WriteIndented = true
185- } ) ;
184+ new JsonSerializerOptions { WriteIndented = true } ) ;
186185
187186 File . WriteAllText ( TempFilePath , serialized ) ;
188187
189188 AtomicWriteSetting ( ) ;
190189 }
190+
191191 public async Task SaveAsync ( )
192192 {
193193 var tempOutput = File . OpenWrite ( TempFilePath ) ;
194194 await JsonSerializer . SerializeAsync ( tempOutput , Data ,
195- new JsonSerializerOptions
196- {
197- WriteIndented = true
198- } ) ;
195+ new JsonSerializerOptions { WriteIndented = true } ) ;
199196 AtomicWriteSetting ( ) ;
200197 }
198+
201199 private void AtomicWriteSetting ( )
202200 {
203201 if ( ! File . Exists ( FilePath ) )
@@ -206,9 +204,9 @@ private void AtomicWriteSetting()
206204 }
207205 else
208206 {
209- File . Replace ( TempFilePath , FilePath , BackupFilePath ) ;
207+ var finalFilePath = new FileInfo ( FilePath ) . LinkTarget ?? FilePath ;
208+ File . Replace ( TempFilePath , finalFilePath , BackupFilePath ) ;
210209 }
211210 }
212-
213211 }
214212}
0 commit comments