Added check for Duplicate UUIDs (see https://keepass2android.codeplex.com/workitem/46)
This commit is contained in:
@@ -54,6 +54,7 @@ namespace keepass2android
|
||||
ClickOkToSelectLocation,
|
||||
FileIsReadOnly,
|
||||
FileIsReadOnlyOnKitkat,
|
||||
CopyFileRequiredForEditing
|
||||
CopyFileRequiredForEditing,
|
||||
DuplicateUuidsError
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,10 +181,20 @@ namespace keepass2android
|
||||
var childGroups = currentGroup.Groups;
|
||||
var childEntries = currentGroup.Entries;
|
||||
|
||||
foreach (PwEntry e in childEntries) {
|
||||
foreach (PwEntry e in childEntries)
|
||||
{
|
||||
if (Entries.ContainsKey(e.Uuid))
|
||||
{
|
||||
throw new DuplicateUuidsException();
|
||||
}
|
||||
Entries [e.Uuid] = e;
|
||||
}
|
||||
foreach (PwGroup g in childGroups) {
|
||||
foreach (PwGroup g in childGroups)
|
||||
{
|
||||
if (Groups.ContainsKey(g.Uuid))
|
||||
{
|
||||
throw new DuplicateUuidsException();
|
||||
}
|
||||
Groups[g.Uuid] = g;
|
||||
PopulateGlobals(g);
|
||||
}
|
||||
@@ -215,6 +225,8 @@ namespace keepass2android
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal class DuplicateUuidsException : Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace keepass2android
|
||||
StatusLogger.UpdateMessage(UiStringKey.loading_database);
|
||||
//get the stream data into a single stream variable (databaseStream) regardless whether its preloaded or not:
|
||||
MemoryStream preloadedMemoryStream = _databaseData == null ? null : _databaseData.Result;
|
||||
MemoryStream databaseStream;
|
||||
MemoryStream databaseStream;
|
||||
if (preloadedMemoryStream != null)
|
||||
databaseStream = preloadedMemoryStream;
|
||||
else
|
||||
@@ -83,12 +83,18 @@ namespace keepass2android
|
||||
foreach (var innerException in e.InnerExceptions)
|
||||
{
|
||||
message = innerException.Message;
|
||||
// Override the message shown with the last (hopefully most recent) inner exception
|
||||
// Override the message shown with the last (hopefully most recent) inner exception
|
||||
Kp2aLog.Log("Exception: " + innerException);
|
||||
}
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + message);
|
||||
return;
|
||||
}
|
||||
catch (DuplicateUuidsException e)
|
||||
{
|
||||
Kp2aLog.Log("Exception: " + e);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError));
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log("Exception: " + e);
|
||||
|
||||
Reference in New Issue
Block a user