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: SelectiveSync: Remove local files of undelected folder de… #5822

Merged
merged 1 commit into from
Jun 8, 2017

Conversation

ogoffart
Copy link
Contributor

@ogoffart ogoffart commented Jun 6, 2017

…spite other modified files

Issue #5783

When the directry that should be removed by selective sync contains changes,
we ignore the whole sub tree instead of only ignoreing new files.
We cannot ignore the whole directory, we need to ignore only the directory
that do not have files to remove

@ogoffart ogoffart requested a review from ckamm June 6, 2017 14:06
@ckamm ckamm added this to the 2.4.0 milestone Jun 6, 2017
ckamm
ckamm previously requested changes Jun 7, 2017
@@ -1179,6 +1180,34 @@ void SyncEngine::checkForPermission(SyncFileItemVector &syncItems)
if ((*it)->_isDirectory) {
for (SyncFileItemVector::iterator it_next = it + 1; it_next != syncItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
it = it_next;
if ((*it)->_direction != SyncFileItem::Up && (*it)->_instruction == CSYNC_INSTRUCTION_REMOVE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why != Up and not == Down? I'd be more comfortable with this pointing specifically at local removes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Add a comment before the if along these lines:

We want to ignore almost all instructions for items inside selective-sync excluded folders. 
The exception are DOWN/REMOVE actions that remove local files and folders that are 
guaranteed to be up-to-date with their server copies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just using the same pattern as above. Normally, conflicts should not happen there. But still I guess it's more clear with == Down, so i'll change it.

needle = SyncFileItemPtr::create();
needle->_file = parentDir;
auto parent_it = std::lower_bound(syncItems.begin(), it, needle);
if (parent_it == syncItems.end() || (*parent_it)->destination() != parentDir) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe at a || !(*parent_it)->_file.startsWith(path) to ensure we're not traversing too far upwards?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

I'm going to do the check slightly differently. (because path ends with '/' but we also need to do it for path itself)

break; // already changed
}
(*parent_it)->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
(*parent_it)->_status = SyncFileItem::NoStatus;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay to keep _errorString set? I think some code considers finished items with a non-empty errorString an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing

…spite other modified files

Issue #5783

When the directry that should be removed by selective sync contains changes,
we ignore the whole sub tree instead of only ignoreing new files.
We cannot ignore the whole directory, we need to ignore only the directory
that do not have files to remove
@ogoffart ogoffart dismissed ckamm’s stale review June 7, 2017 15:24

change updated.

@ogoffart ogoffart merged commit 3314a47 into master Jun 8, 2017
@ogoffart ogoffart deleted the origin/selective-sync-db branch June 8, 2017 12:53
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.

2 participants