stephenh / mirror

A tool for real-time, two-way sync for remote (e.g. desktop/laptop) development
Apache License 2.0
391 stars 35 forks source link

mirror doesn't work two-way in all cases #4

Closed akheron closed 7 years ago

akheron commented 7 years ago

Hi! This project is awesome, exactly what I need.

I'm on Linux, have watchman installed, and I'm trying to sync a directory with just one file currently. Initially, the file exists in desktop and the directory is empty on laptop. mirror is in PATH in both machines.

On desktop, I cd to the directory I want to sync, and run this command: mirror server. On laptop, I also cd to the directory, and run this command: mirror client -h desktop -l . -r .. Initially, the file is synced correctly to laptop.

After starting mirror on both machines, if I edit the file on laptop first and then on desktop, everything works as expected afterwards, and the file syncs in both ways.

But if I make the first edit on desktop, then changes made on on laptop don't sync back to desktop. Furthermore, when I Ctrl-C the mirror running on laptop, the file is emptied. Not removed, but emptied.

stephenh commented 7 years ago

Hi! This project is awesome, exactly what I need

Thanks! Good to hear. :-)

But if I make the first edit on desktop, then changes made on on laptop don't sync back to desktop.

Hm...that is strange.

Furthermore, when I Ctrl-C the mirror running on laptop, the file is emptied.

That is also very strange...in theory I don't have any "on interrupt" handlers in mirror.

Not removed, but emptied.

I have actually seen mirror create empty files before, especially while initially developing the sync logic. It hasn't happen for me in awhile, but I believe it could be happening...

Just curious, but do you have significant clock skew between your two machines?

I'm wondering if there is something odd like the desktop is X minutes in the future, such that any write on it, even an "empty" write, is considered newer by the laptop.

Maybe try running ntp or what not on both machines and see if it corrects your clock (I believe when you run it it will tell you "I fixed your time by X minutes").

If that is not it, I'll have to do some more brainstorming.

If that is it, that will be good to fix it, but I am not looking forward to somehow proactively detecting clock skew between the two machines.

akheron commented 7 years ago

Ah, that was it! The laptop's clock was about 35 seconds behind. Now that I enabled NTP, everything works. Thanks a lot!

stephenh commented 7 years ago

Whew! Glad that was it. I put in a small fix to hopefully catch this for other users going forward. I need to do a bit more testing of it but it should work.

Thanks for reporting the issue, so I could fix it for you + future users that would have run into this, instead of just giving up and moving on. :-)