App icon; language/theme follow Windows on first run; flush save on exit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,29 @@ namespace ReminderOrganizer.Services
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void Save(AppData data)
|
||||
{
|
||||
_writeLock.Wait();
|
||||
try
|
||||
{
|
||||
var tmp = DataFilePath + ".tmp";
|
||||
File.WriteAllText(tmp, JsonSerializer.Serialize(data, _jsonOptions));
|
||||
Commit(tmp);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_writeLock.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private void Commit(string tmp)
|
||||
{
|
||||
if (File.Exists(DataFilePath))
|
||||
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
|
||||
else
|
||||
File.Move(tmp, DataFilePath);
|
||||
}
|
||||
|
||||
public async Task SaveAsync(AppData data)
|
||||
{
|
||||
await _writeLock.WaitAsync();
|
||||
@@ -92,10 +115,7 @@ namespace ReminderOrganizer.Services
|
||||
var json = JsonSerializer.Serialize(data, _jsonOptions);
|
||||
var tmp = DataFilePath + ".tmp";
|
||||
await File.WriteAllTextAsync(tmp, json);
|
||||
if (File.Exists(DataFilePath))
|
||||
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
|
||||
else
|
||||
File.Move(tmp, DataFilePath);
|
||||
Commit(tmp);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user