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

Keep both local and remote nodes with mismatched kinds #26

Closed
wants to merge 13 commits into from

Conversation

linabutler
Copy link
Contributor

For mismatched kinds, we keep both nodes with new GUIDs. This is an
edge case: Places maintenance on Desktop can change an item's
kind without changing its GUID, but this should be rare.

In general, we can't meaningfully pick a side when two items have
different kinds (a bookmark and a folder with children? a bookmark and
a separator?), so we keep both, with new structure, to avoid possible
data loss.

See #13.

This returns an iterator that yields the merged node's descendants, in
level order.
Before `Unchanged`, `Local` meant "keep local and maybe upload", and
`LocalWithNewStructure` meant "keep local and always upload". Now
that `Unchanged` exists, `Local` means "keep local and upload", so
`LocalWithNewStructure` is redundant.

Further, it wasn't obvious that `Local { remote_node: None }` meant
the item only exists locally, and should be uploaded unconditionally,
and `Remote { local_node: None }` meant the item only exists remotely,
and should be applied unconditionally. This commit changes `Local`
and `Remote` to mean "exists on both sides, but prefer one", and adds
`LocalOnly`, `RemoteOnly`, and `RemoteOnlyWithNewStructure` to mean
"exists on one side, so take unconditionally".

To that end, this commit treats remotely changed user content roots as
`Unchanged`. As of bug 1432614, roots don't have user-editable titles,
so applying remote title changes is unnecessary. However, we also don't
mark the roots as `Local`, because that would mean we'd reupload the
root _every time_ it was changed remotely.

Finally, we want callers to easily determine whether to apply remote
changes, and upload local and new changes. This commit adds
`MergeState::{should_apply, should_upload}()` for that.
For mismatched kinds, we keep both nodes with new GUIDs. This is an
edge case: Places maintenance on Desktop can change an item's
kind without changing its GUID, but this should be rare.

In general, we can't meaningfully pick a side when two items have
different kinds (a bookmark and a folder with children? a bookmark and
a separator?), so we keep both, with new structure, to avoid possible
data loss.

See #13.
@codecov-io
Copy link

codecov-io commented Feb 17, 2019

Codecov Report

Merging #26 into desktop will decrease coverage by 9.72%.
The diff coverage is 69.91%.

Impacted file tree graph

@@             Coverage Diff             @@
##           desktop      #26      +/-   ##
===========================================
- Coverage    95.15%   85.43%   -9.73%     
===========================================
  Files            7        6       -1     
  Lines         2995     1977    -1018     
===========================================
- Hits          2850     1689    -1161     
- Misses         145      288     +143
Impacted Files Coverage Δ
src/driver.rs 42.85% <ø> (-7.15%) ⬇️
src/tree.rs 74.57% <63.06%> (-9.5%) ⬇️
src/merge.rs 81.55% <63.17%> (-17.19%) ⬇️
src/guid.rs 88.73% <96.77%> (-3.38%) ⬇️
src/tests.rs 99.84% <98.41%> (-0.16%) ⬇️
src/error.rs 0% <0%> (-36%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d9e796...b2410ff. Read the comment docs.

} else {
// For mismatched kinds, we keep both nodes with new GUIDs. This is
// an edge case: Places maintenance on Desktop can change an item's
// kind without changing its GUID (bug XXXXXXX), but this should be
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's where we change bookmarks without URLs to folders, and anything with a URLs to bookmarks. I should file a bug so that we also update the GUID when we do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, probably. As a note, I'm somewhat unconvinced that keeping both items is really the right call here. Yes, it avoids data loss, but these are items that are fairly corrupted to begin with.

That said, I'm not sure how that would actually work out, so we should probably just defer to your judgement here :)

@linabutler
Copy link
Contributor Author

Thinking some more, I wonder if we can drop this PR for now, have mismatched kinds return errors, and see what telemetry tells us. It's a chunk of complexity (in the old engine, too, where we remove and reinsert) for something that shouldn't really happen.

The only mismatches we know about are livemark-folder and bookmark-query. The former shouldn't 🤞 be a problem now that we don't support livemarks, and the latter are totally fine. We can revisit if it turns out to be an issue in the wild.

Copy link
Contributor

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

God, what a headache.

} else {
// For mismatched kinds, we keep both nodes with new GUIDs. This is
// an edge case: Places maintenance on Desktop can change an item's
// kind without changing its GUID (bug XXXXXXX), but this should be
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, probably. As a note, I'm somewhat unconvinced that keeping both items is really the right call here. Yes, it avoids data loss, but these are items that are fairly corrupted to begin with.

That said, I'm not sure how that would actually work out, so we should probably just defer to your judgement here :)

@thomcc
Copy link
Contributor

thomcc commented Feb 20, 2019

Oh, I missed your comment about this not being necessary. If it's not, then yeah I definitely am all for sitting on it and waiting for telemetry!

@linabutler
Copy link
Contributor Author

Let's hold off on this and see what telemetry tells us. We can always dust it off later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants