Skip to content

Commit

Permalink
Fixes issue where entire settings file wasn't being overwritten, left…
Browse files Browse the repository at this point in the history
…over data appeared if the new file was shorter
  • Loading branch information
Michael Brown committed Feb 22, 2022
1 parent 652efbb commit 2f7d0b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Binner/Binner.Web/Controllers/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public SystemController(AutoMapper.IMapper mapper, IServiceContainer container,
/// </summary>
/// <returns></returns>
[HttpPut("settings")]
public IActionResult GetSettings(SettingsRequest request)
public IActionResult SaveSettings(SettingsRequest request)
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion Binner/Library/Binner.Common/Services/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void SaveSettingsAs<T>(T instance, string sectionName, string filename, b
throw new BinnerConfigurationException($"There is no section named '{sectionName}' in the configuration file '{filename}'!");

var jsonOutput = JsonConvert.SerializeObject(json, serializerSettings);
using var file = File.Open(filename, FileMode.Open, FileAccess.Write, FileShare.Read);
using var file = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
var buffer = Encoding.Default.GetBytes(jsonOutput);
file.Write(buffer, 0, buffer.Length);
file.Close();
Expand Down

0 comments on commit 2f7d0b4

Please sign in to comment.