mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 08:00:16 -04:00
Save error is now handled via Messenger instead of unhandled exception handler (which didn't work)
Save as actually works now WIP Styles Code cleanup
This commit is contained in:
@@ -27,26 +27,19 @@ namespace ModernKeePass.Application.Database.Commands.SaveDatabase
|
||||
|
||||
try
|
||||
{
|
||||
byte[] contents;
|
||||
if (string.IsNullOrEmpty(message.FilePath))
|
||||
if (!string.IsNullOrEmpty(message.FilePath))
|
||||
{
|
||||
contents = await _database.SaveDatabase();
|
||||
|
||||
// Test DB integrity before writing changes to file
|
||||
_database.CloseDatabase();
|
||||
await _database.ReOpen(contents);
|
||||
|
||||
await _file.WriteBinaryContentsToFile(_database.FileAccessToken, contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newFileContents = await _file.OpenBinaryFile(message.FilePath);
|
||||
contents = await _database.SaveDatabase(newFileContents);
|
||||
await _file.WriteBinaryContentsToFile(message.FilePath, contents);
|
||||
|
||||
_file.ReleaseFile(_database.FileAccessToken);
|
||||
_database.FileAccessToken = message.FilePath;
|
||||
}
|
||||
|
||||
var contents = await _database.SaveDatabase();
|
||||
|
||||
// Test DB integrity
|
||||
_database.CloseDatabase();
|
||||
await _database.ReOpen(contents);
|
||||
|
||||
// Transactional write to file
|
||||
await _file.WriteBinaryContentsToFile(_database.FileAccessToken, contents);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
Reference in New Issue
Block a user