mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00

Removed useless isdirty field in entry When an app can't be saved on suspend, don't reopen it to avoid possible de-sync
26 lines
930 B
C#
26 lines
930 B
C#
using MediatR;
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
using ModernKeePass.Domain.Exceptions;
|
|
|
|
namespace ModernKeePass.Application.Database.Commands.CloseDatabase
|
|
{
|
|
public class CloseDatabaseCommand: IRequest
|
|
{
|
|
public class CloseDatabaseCommandHandler : IRequestHandler<CloseDatabaseCommand>
|
|
{
|
|
private readonly IDatabaseProxy _database;
|
|
|
|
public CloseDatabaseCommandHandler(IDatabaseProxy database)
|
|
{
|
|
_database = database;
|
|
}
|
|
public void Handle(CloseDatabaseCommand message)
|
|
{
|
|
if (!_database.IsOpen) throw new DatabaseClosedException();
|
|
// Prevent reopening the database due to possible de-synchronization between app and data
|
|
if (_database.IsDirty) _database.FileAccessToken = null;
|
|
_database.CloseDatabase();
|
|
}
|
|
}
|
|
}
|
|
} |