Skip to content

Add check to see if merging is required#1882

Closed
louib wants to merge 7 commits intokeepassxreboot:developfrom
louib:needs_merging
Closed

Add check to see if merging is required#1882
louib wants to merge 7 commits intokeepassxreboot:developfrom
louib:needs_merging

Conversation

@louib
Copy link
Copy Markdown
Member

@louib louib commented Apr 28, 2018

Add a function to detect when merging is needed.

@mbilloo This is what I had in mind when filing
#1010

I think @droidmonkey would like to have your deep comparison operator from #1836 merged nonetheless. Can you open a new PR
for that?

Motivation and context

Fixes #1010

How has this been tested?

Locally + unit tests.

Types of changes

  • ✅ Bug fix (non-breaking change which fixes an issue)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have added tests to cover my changes.

@louib louib added the bug label Apr 28, 2018
@louib louib requested review from a team and droidmonkey April 28, 2018 16:16
@droidmonkey droidmonkey changed the title Needs merging Add check to see if merging is required May 6, 2018
@louib
Copy link
Copy Markdown
Member Author

louib commented Jul 4, 2018

@TheZ3ro @droidmonkey can you guys take a look at this one?

Copy link
Copy Markdown
Member

@droidmonkey droidmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest problem with this implementation is it only compares the root group with the supplied group. It also does not compare recursively, just the top layer. This needs to be reworked before merge.

I prefer you add the recursiveness in the database merge function, leave the group "needsMerging" function to compare the top layers as presented to the function.


bool Group::needsMerging(const Group* otherGroup)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra line


Group* rootGroup = this;
while (rootGroup->parentGroup()) {
rootGroup = rootGroup->parentGroup();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing this up to the "true" root group is not appropriate. This function is meant to compare two groups as presented. By doing these actions here we cannot reuse this function to compare two arbitrary groups.


// detect changes in entries
const QList<Entry*> dbEntries = otherGroup->entries();
for (Entry* otherEntry : dbEntries) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Entry* otherEntry
Prevents any possibility of copying

// detect changes in entries
const QList<Entry*> dbEntries = otherGroup->entries();
for (Entry* otherEntry : dbEntries) {
Entry* existingEntry = rootGroup->findEntryByUuid(otherEntry->uuid());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Entry*


// detect changes in groups
const QList<Group*> dbChildren = otherGroup->children();
for (Group* otherGroup : dbChildren) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Group*

// detect changes in groups
const QList<Group*> dbChildren = otherGroup->children();
for (Group* otherGroup : dbChildren) {
Group* existingGroup = rootGroup->findChildByUuid(otherGroup->uuid());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Group*

@droidmonkey droidmonkey added this to the v2.4.0 milestone Sep 19, 2018
@louib
Copy link
Copy Markdown
Member Author

louib commented Nov 4, 2018

Closing this one in favor of #2457

@louib louib closed this Nov 4, 2018
@droidmonkey droidmonkey removed this from the v2.4.0 milestone Nov 29, 2018
@phoerious phoerious added pr: bugfix Pull request fixes a bug and removed bug labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: bugfix Pull request fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merging always marks the database as dirty

3 participants