diff --git a/ModernKeePass/App.xaml.cs b/ModernKeePass/App.xaml.cs
index ec0e157..10980aa 100644
--- a/ModernKeePass/App.xaml.cs
+++ b/ModernKeePass/App.xaml.cs
@@ -125,7 +125,7 @@ namespace ModernKeePass
Window.Current.Activate();
}
- private async void OnResuming(object sender, object e)
+ private void OnResuming(object sender, object e)
{
var currentFrame = Window.Current.Content as Frame;
var database = DatabaseService.Instance;
@@ -138,7 +138,7 @@ namespace ModernKeePass
}
try
{
- if (database.CompositeKey != null) await database.ReOpen();
+ if (database.CompositeKey != null) database.ReOpen();
}
catch (Exception ex)
{
@@ -167,14 +167,14 @@ namespace ModernKeePass
///
/// The source of the suspend request.
/// Details about the suspend request.
- private async void OnSuspending(object sender, SuspendingEventArgs e)
+ private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
var database = DatabaseService.Instance;
try
{
if (SettingsService.Instance.GetSetting("SaveSuspend", true)) database.Save();
- await database.Close(false);
+ database.Close(false);
}
catch (Exception exception)
{
diff --git a/ModernKeePass/Interfaces/IDatabaseService.cs b/ModernKeePass/Interfaces/IDatabaseService.cs
index 4c24e6d..36b071b 100644
--- a/ModernKeePass/Interfaces/IDatabaseService.cs
+++ b/ModernKeePass/Interfaces/IDatabaseService.cs
@@ -23,12 +23,12 @@ namespace ModernKeePass.Interfaces
bool IsClosed { get; }
bool HasChanged { get; set; }
- Task Open(CompositeKey key, bool createNew = false);
- Task ReOpen();
+ void Open(CompositeKey key, bool createNew = false);
+ void ReOpen();
void Save();
void Save(StorageFile file);
void CreateRecycleBin(string title);
void AddDeletedItem(PwUuid id);
- Task Close(bool releaseFile = true);
+ void Close(bool releaseFile = true);
}
}
\ No newline at end of file
diff --git a/ModernKeePass/Services/DatabaseService.cs b/ModernKeePass/Services/DatabaseService.cs
index 3de74dd..53b06ac 100644
--- a/ModernKeePass/Services/DatabaseService.cs
+++ b/ModernKeePass/Services/DatabaseService.cs
@@ -1,5 +1,4 @@
using System;
-using System.Threading.Tasks;
using Windows.Storage;
using Microsoft.HockeyApp;
using ModernKeePass.Exceptions;
@@ -19,7 +18,6 @@ namespace ModernKeePass.Services
{
private readonly PwDatabase _pwDatabase = new PwDatabase();
private readonly ISettingsService _settings;
- private StorageFile _realDatabaseFile;
private StorageFile _databaseFile;
private GroupVm _recycleBin;
@@ -97,9 +95,8 @@ namespace ModernKeePass.Services
/// The database composite key
/// True to create a new database before opening it
/// An error message, if any
- public async Task Open(CompositeKey key, bool createNew = false)
+ public void Open(CompositeKey key, bool createNew = false)
{
- // TODO: Check if there is an existing backup file
try
{
if (key == null)
@@ -124,18 +121,6 @@ namespace ModernKeePass.Services
}
}
else _pwDatabase.Open(ioConnection, key, new NullStatusLogger());
-
- //if (!_pwDatabase.IsOpen) return;
-
- // Copy database in temp directory and use this file for operations
- if (_settings.GetSetting("AntiCorruption"))
- {
- _realDatabaseFile = _databaseFile;
- var backupFile =
- await ApplicationData.Current.RoamingFolder.CreateFileAsync(Name,
- CreationCollisionOption.FailIfExists);
- Save(backupFile);
- }
RootGroup = new GroupVm(_pwDatabase.RootGroup, null, RecycleBinEnabled ? _pwDatabase.RecycleBinUuid : null);
}
@@ -146,9 +131,9 @@ namespace ModernKeePass.Services
}
}
- public async Task ReOpen()
+ public void ReOpen()
{
- await Open(CompositeKey);
+ Open(CompositeKey);
}
///
@@ -160,12 +145,6 @@ namespace ModernKeePass.Services
try
{
_pwDatabase.Save(new NullStatusLogger());
-
- // Test if save worked correctly
- if (_settings.GetSetting("AntiCorruption"))
- {
- _pwDatabase.Open(_pwDatabase.IOConnectionInfo, _pwDatabase.MasterKey, new NullStatusLogger());
- }
}
catch (Exception e)
{
@@ -195,17 +174,9 @@ namespace ModernKeePass.Services
///
/// Close the currently opened database
///
- public async Task Close(bool releaseFile = true)
+ public void Close(bool releaseFile = true)
{
_pwDatabase?.Close();
-
- // Restore the backup DB to the original one
- if (_settings.GetSetting("AntiCorruption"))
- {
- if (_pwDatabase != null && _pwDatabase.Modified)
- Save(_realDatabaseFile);
- await DatabaseFile.DeleteAsync();
- }
if (releaseFile) DatabaseFile = null;
}
diff --git a/ModernKeePass/Services/LicenseService.cs b/ModernKeePass/Services/LicenseService.cs
index efa276e..56d507d 100644
--- a/ModernKeePass/Services/LicenseService.cs
+++ b/ModernKeePass/Services/LicenseService.cs
@@ -50,7 +50,7 @@ namespace ModernKeePass.Services
case ProductPurchaseStatus.AlreadyPurchased:
return (int) PurchaseResult.AlreadyPurchased;
default:
- throw new ArgumentOutOfRangeException(nameof(purchaseResults.Status));
+ throw new IndexOutOfRangeException("Purchase results status does not have a valid value");
}
}
diff --git a/ModernKeePass/ViewModels/CompositeKeyVm.cs b/ModernKeePass/ViewModels/CompositeKeyVm.cs
index f293ccb..2115226 100644
--- a/ModernKeePass/ViewModels/CompositeKeyVm.cs
+++ b/ModernKeePass/ViewModels/CompositeKeyVm.cs
@@ -125,7 +125,7 @@ namespace ModernKeePass.ViewModels
try
{
_isOpening = true;
- await Database.Open(CreateCompositeKey(), createNew);
+ Database.Open(CreateCompositeKey(), createNew);
await Task.Run(() => RootGroup = Database.RootGroup);
return true;
}
diff --git a/ModernKeePass/ViewModels/SaveVm.cs b/ModernKeePass/ViewModels/SaveVm.cs
index 4531317..c10d960 100644
--- a/ModernKeePass/ViewModels/SaveVm.cs
+++ b/ModernKeePass/ViewModels/SaveVm.cs
@@ -1,5 +1,4 @@
-using System.Threading.Tasks;
-using Windows.Storage;
+using Windows.Storage;
using ModernKeePass.Interfaces;
using ModernKeePass.Services;
@@ -15,11 +14,10 @@ namespace ModernKeePass.ViewModels
_database = database;
}
- public async Task Save(bool close = true)
+ public void Save(bool close = true)
{
_database.Save();
- if (close)
- await _database.Close();
+ if (close) _database.Close();
}
public void Save(StorageFile file)
diff --git a/ModernKeePass/Views/BasePages/LayoutAwarePageBase.cs b/ModernKeePass/Views/BasePages/LayoutAwarePageBase.cs
index c0a7b38..88e33d8 100644
--- a/ModernKeePass/Views/BasePages/LayoutAwarePageBase.cs
+++ b/ModernKeePass/Views/BasePages/LayoutAwarePageBase.cs
@@ -62,9 +62,6 @@ namespace ModernKeePass.Views.BasePages
/// session. The state will be null the first time a page is visited.
protected void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
- // TODO: Assign a bindable group to Me.DefaultViewModel("Group")
- // TODO: Assign a collection of bindable items to Me.DefaultViewModel("Items")
-
if (e.PageState == null)
{
// When this is a new page, select the first item automatically unless logical page
diff --git a/ModernKeePass/Views/MainPageFrames/SaveDatabasePage.xaml.cs b/ModernKeePass/Views/MainPageFrames/SaveDatabasePage.xaml.cs
index b32cea0..404b12d 100644
--- a/ModernKeePass/Views/MainPageFrames/SaveDatabasePage.xaml.cs
+++ b/ModernKeePass/Views/MainPageFrames/SaveDatabasePage.xaml.cs
@@ -28,9 +28,9 @@ namespace ModernKeePass.Views
_mainFrame = e.Parameter as Frame;
}
- private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
+ private void SaveButton_OnClick(object sender, RoutedEventArgs e)
{
- await Model.Save();
+ Model.Save();
_mainFrame.Navigate(typeof(MainPage));
}
diff --git a/ModernKeePassApp.Test/Mock/DatabaseServiceMock.cs b/ModernKeePassApp.Test/Mock/DatabaseServiceMock.cs
index fa809bd..767f5c5 100644
--- a/ModernKeePassApp.Test/Mock/DatabaseServiceMock.cs
+++ b/ModernKeePassApp.Test/Mock/DatabaseServiceMock.cs
@@ -1,5 +1,4 @@
using System;
-using System.Threading.Tasks;
using ModernKeePass.Interfaces;
using ModernKeePass.ViewModels;
using ModernKeePassLib;
@@ -50,13 +49,10 @@ namespace ModernKeePassApp.Test.Mock
throw new NotImplementedException();
}
- public Task Close(bool releaseFile = true)
+ public void Close(bool releaseFile = true)
{
- return Task.Run(() =>
- {
- _isClosed = true;
- _isOpen = false;
- });
+ _isClosed = true;
+ _isOpen = false;
}
public void CreateRecycleBin(string title)
@@ -64,19 +60,16 @@ namespace ModernKeePassApp.Test.Mock
throw new NotImplementedException();
}
- public Task Open(CompositeKey key, bool createNew = false)
+ public void Open(CompositeKey key, bool createNew = false)
{
_compositeKey = key;
- return Task.Run(() =>
- {
- _isOpen = true;
- _isClosed = false;
- });
+ _isOpen = true;
+ _isClosed = false;
}
- public async Task ReOpen()
+ public void ReOpen()
{
- await Open(_compositeKey);
+ Open(_compositeKey);
}
public void Save()