Make sure "duplicate UUID" error is not repeated after fixing the db
Make sure no duplicate UUIDs are created by cancelling the save operation and saving again Reverse sort order for modification date (now descending) Added beta warning for kdb change log + manifest for 0.9.7-pre1
This commit is contained in:
@@ -56,6 +56,7 @@ namespace keepass2android
|
||||
FileIsReadOnlyOnKitkat,
|
||||
CopyFileRequiredForEditing,
|
||||
DuplicateUuidsError,
|
||||
DuplicateUuidsErrorAdditional
|
||||
DuplicateUuidsErrorAdditional,
|
||||
KdbBetaWarning
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,21 +110,31 @@ namespace keepass2android
|
||||
Stream s = databaseData ?? fileStorage.OpenFileForRead(iocInfo);
|
||||
var fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo);
|
||||
PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat);
|
||||
LastFileVersion = fileVersion;
|
||||
try
|
||||
{
|
||||
LastFileVersion = fileVersion;
|
||||
|
||||
status.UpdateSubMessage("");
|
||||
|
||||
Root = pwDatabase.RootGroup;
|
||||
PopulateGlobals(Root);
|
||||
|
||||
Loaded = true;
|
||||
KpDatabase = pwDatabase;
|
||||
SearchHelper = new SearchDbHelper(app);
|
||||
|
||||
_databaseFormat = databaseFormat;
|
||||
|
||||
CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Clear();
|
||||
throw;
|
||||
}
|
||||
|
||||
status.UpdateSubMessage("");
|
||||
|
||||
Root = pwDatabase.RootGroup;
|
||||
PopulateGlobals(Root);
|
||||
|
||||
|
||||
Loaded = true;
|
||||
KpDatabase = pwDatabase;
|
||||
SearchHelper = new SearchDbHelper(app);
|
||||
|
||||
_databaseFormat = databaseFormat;
|
||||
|
||||
CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -24,10 +24,16 @@ namespace keepass2android
|
||||
{
|
||||
public class KdbDatabaseFormat: IDatabaseFormat
|
||||
{
|
||||
private readonly IKp2aApp _app;
|
||||
private Dictionary<PwUuid, AdditionalGroupData> _groupData = new Dictionary<PwUuid, AdditionalGroupData>();
|
||||
private static readonly DateTime _expireNever = new DateTime(2999,12,28,23,59,59);
|
||||
private List<PwEntryV3> _metaStreams;
|
||||
|
||||
public KdbDatabaseFormat(IKp2aApp app)
|
||||
{
|
||||
_app = app;
|
||||
}
|
||||
|
||||
public void PopulateDatabaseFromStream(PwDatabase db, Stream s, IStatusLogger slLogger)
|
||||
{
|
||||
#if !EXCLUDE_KEYTRANSFORM
|
||||
@@ -215,7 +221,7 @@ namespace keepass2android
|
||||
public bool CanWrite { get { return true; } }
|
||||
public string SuccessMessage { get
|
||||
{
|
||||
return "";
|
||||
return _app.GetResourceString(UiStringKey.KdbBetaWarning);
|
||||
} }
|
||||
|
||||
public void Save(PwDatabase kpDatabase, Stream stream)
|
||||
|
||||
@@ -48,7 +48,15 @@ namespace keepass2android
|
||||
|
||||
public override void Run() {
|
||||
StatusLogger.UpdateMessage(UiStringKey.AddingEntry);
|
||||
_parentGroup.AddEntry(_entry, true);
|
||||
|
||||
//make sure we're not adding the entry if it was added before.
|
||||
//(this might occur in very rare cases where the user dismissis the save dialog
|
||||
//by rotating the screen while saving and then presses save again)
|
||||
if (_parentGroup.FindEntry(_entry.Uuid, false) == null)
|
||||
{
|
||||
_parentGroup.AddEntry(_entry, true);
|
||||
}
|
||||
|
||||
|
||||
// Commit to disk
|
||||
SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun);
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (OldFormatException)
|
||||
{
|
||||
_format = new KdbDatabaseFormat();
|
||||
_format = new KdbDatabaseFormat(_app);
|
||||
TryLoad(databaseStream);
|
||||
}
|
||||
catch (InvalidCompositeKeyException)
|
||||
|
||||
Reference in New Issue
Block a user