Skip to content

Commit

Permalink
fix(ASFFreeGamesOptions): Ensure correct file size when saving config…
Browse files Browse the repository at this point in the history
…uration

- Updated `Save` method to address potential issue with file size after writing JSON data.
- Implemented option to set file size explicitly after writing using `fs.SetLength(fs.Position)`.

This change prevents potential corruption in the saved configuration file by ensuring the correct size reflects the actual JSON content.
  • Loading branch information
maxisoft committed May 4, 2024
1 parent e4fc3ae commit 465bcb9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ASFFreeGames/Configurations/ASFFreeGamesOptionsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static async Task Save(ASFFreeGamesOptions options, CancellationToken can

// Use JsonSerializerOptions.PropertyNamingPolicy to specify the JSON property naming convention
await JsonSerializer.SerializeAsync(fs, options, cancellationToken: cancellationToken).ConfigureAwait(false);
fs.SetLength(fs.Position);
}
finally {
Semaphore.Release();
Expand Down

0 comments on commit 465bcb9

Please sign in to comment.