mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
WIP ViewModelLocator - Messenger and Recent issues
Refactoring Code cleanup
This commit is contained in:
@@ -25,18 +25,19 @@ namespace ModernKeePass.Application.Database.Queries.OpenDatabase
|
||||
|
||||
public async Task Handle(OpenDatabaseQuery message)
|
||||
{
|
||||
if (_database.IsOpen) throw new DatabaseOpenException();
|
||||
if (_database.IsDirty) throw new DatabaseOpenException();
|
||||
|
||||
var file = await _file.OpenBinaryFile(message.FilePath);
|
||||
var hasKeyFile = !string.IsNullOrEmpty(message.KeyFilePath);
|
||||
await _database.Open(file, new Credentials
|
||||
{
|
||||
KeyFileContents = !string.IsNullOrEmpty(message.KeyFilePath) ? await _file.OpenBinaryFile(message.KeyFilePath): null,
|
||||
KeyFileContents = hasKeyFile ? await _file.OpenBinaryFile(message.KeyFilePath): null,
|
||||
Password = message.Password
|
||||
});
|
||||
if (hasKeyFile) _file.ReleaseFile(message.KeyFilePath);
|
||||
_database.Size = file.Length;
|
||||
_database.FileAccessToken = message.FilePath;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user