Avoid showing the keep changes/overwrite dialogs when unnecessary.

For #6525 and the issue mentioned in #5614.

@peterflynn - might be good for you to review this one.

I tested all the cases I can think of, but this seems like it would be good to unit test - though I wasn't able to find any existing unit tests for the file sync stuff. Is it worth starting up a new suite?