Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyncEngine: Fix renames making hierarchy inversion #6695

Merged
merged 1 commit into from
Aug 16, 2018
Merged

SyncEngine: Fix renames making hierarchy inversion #6695

merged 1 commit into from
Aug 16, 2018

Conversation

ogoffart
Copy link
Contributor

@ogoffart ogoffart commented Aug 7, 2018

Issue #6694

This is not a problem in the new_discovery_algo branch, but let's fix that for 2.5

@ogoffart ogoffart requested review from guruz and ckamm August 7, 2018 07:35
@ogoffart ogoffart changed the title SyncEngine: Fix renmaes making hierarchy inversion SyncEngine: Fix renames making hierarchy inversion Aug 9, 2018
@guruz guruz added this to the 2.5.0 milestone Aug 9, 2018
QCOMPARE(fakeFolder.currentLocalState(), expectedState);
QCOMPARE(fakeFolder.currentRemoteState(), expectedState);

/* FIXME
Copy link
Contributor

Choose a reason for hiding this comment

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

FIXME

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this test is still failing. Fixing it would be quite some work and i think this can wait 2.6

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, since it hasn't come up before...

auto original_it = _renamedFolders.constFind(original);
if (original_it != _renamedFolders.constEnd() && it->startsWith(*original_it)) {
return original; // Issue #6694: "hirarchy inversion"
}
Copy link
Contributor

@ckamm ckamm Aug 14, 2018

Choose a reason for hiding this comment

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

I don't get this logic. Are you sure it doesn't indicate we should reverse the order of traversing paths in the while?

As far as I understand (haven't tested!) our renamedFolders will have two entries if "/Documents/Empty" is renamed to "/Empty/Documents":

/Documents -> /Empty/Documents
/Documents/Empty -> /Empty

Previously the function should have mapped "/Documents/Empty" to "/Empty/Documents/Empty" because the first parent directory rename is appied. With your change it'll be "/Empty/Documents" because the full path rename is taken instead.

There are probably corner cases now with three-level paths? Why aren't we taking the longest applicable rename path instead of the shortest?

(if the current logic is correct, I'd like more comments explaining it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously the function should have mapped "/Documents/Empty" to "/Empty/Documents/Empty" because the first parent directory rename is appied.

Yes, that's correct and that was the bug.

But with my change it will return the unchanged original .

Yes, there will be problem with three-level path when each level is renamed, or with cycle that involve several folder (as the FIXME test is testing). But this fix for that is more complicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok! Then the problem was that there was no indication that this was just fixing the most common problem in time for 2.5. Could you add something along the lines of // band-aid to fix a common problem, there's a larger issue here with ... like in example ...?

Copy link
Contributor Author

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

This fix is only for the particualr case in issue #6694, but the problem is actually much bigger and a bigger change is required which i do not think is in the scope for 2.5
Should I discard this change completely and only make a good fix in 2.6 ?

QCOMPARE(fakeFolder.currentLocalState(), expectedState);
QCOMPARE(fakeFolder.currentRemoteState(), expectedState);

/* FIXME
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this test is still failing. Fixing it would be quite some work and i think this can wait 2.6

auto original_it = _renamedFolders.constFind(original);
if (original_it != _renamedFolders.constEnd() && it->startsWith(*original_it)) {
return original; // Issue #6694: "hirarchy inversion"
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously the function should have mapped "/Documents/Empty" to "/Empty/Documents/Empty" because the first parent directory rename is appied.

Yes, that's correct and that was the bug.

But with my change it will return the unchanged original .

Yes, there will be problem with three-level path when each level is renamed, or with cycle that involve several folder (as the FIXME test is testing). But this fix for that is more complicated.

@ckamm ckamm merged commit 4a3fce5 into 2.5 Aug 16, 2018
@ckamm ckamm deleted the fix-6694 branch August 16, 2018 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants