Resuming correctly re-opens the previsouly opened database

This commit is contained in:
Geoffroy BONNEVILLE
2020-05-02 14:39:42 +02:00
parent 654bd6b4e5
commit 97b10baedc
4 changed files with 4 additions and 6 deletions

View File

@@ -18,10 +18,6 @@ namespace ModernKeePass.Application.Database.Commands.CloseDatabase
{ {
if (!_database.IsOpen) throw new DatabaseClosedException(); if (!_database.IsOpen) throw new DatabaseClosedException();
_database.CloseDatabase(); _database.CloseDatabase();
// Cleanup
_database.FileAccessToken = null;
_database.Size = 0;
} }
} }
} }

View File

@@ -20,7 +20,8 @@ namespace ModernKeePass.Application.Database.Queries.ReOpenDatabase
public async Task Handle(ReOpenDatabaseQuery message) public async Task Handle(ReOpenDatabaseQuery message)
{ {
if (!_database.IsOpen) throw new DatabaseClosedException(); if (_database.IsOpen) throw new DatabaseOpenException();
if (string.IsNullOrEmpty(_database.FileAccessToken)) throw new DatabaseClosedException();
var file = await _file.OpenBinaryFile(_database.FileAccessToken); var file = await _file.OpenBinaryFile(_database.FileAccessToken);
await _database.ReOpen(file); await _database.ReOpen(file);

View File

@@ -179,7 +179,7 @@ namespace ModernKeePass
_notification.Show("App resumed", "Database reopened (changes were saved)"); _notification.Show("App resumed", "Database reopened (changes were saved)");
#endif #endif
} }
catch (Exception) catch (DatabaseClosedException)
{ {
_navigation.NavigateTo(Constants.Navigation.MainPage); _navigation.NavigateTo(Constants.Navigation.MainPage);
#if DEBUG #if DEBUG

View File

@@ -1,4 +1,5 @@
[<img src="https://geogeob.visualstudio.com/_apis/public/build/definitions/04291454-0e79-47a4-9502-5bd374804ccf/2/badge"/>](https://geogeob.visualstudio.com/_apis/public/build/index?definitionId=2) [<img src="https://geogeob.visualstudio.com/_apis/public/build/definitions/04291454-0e79-47a4-9502-5bd374804ccf/2/badge"/>](https://geogeob.visualstudio.com/_apis/public/build/index?definitionId=2)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ModernKeePass&metric=alert_status)](https://sonarcloud.io/dashboard?id=ModernKeePass)
# Introduction # Introduction
**ModernKeePass** is port of the classic Windows application KeePass 2.x for the Windows Store. **ModernKeePass** is port of the classic Windows application KeePass 2.x for the Windows Store.