Open ediphy-azorab opened 5 years ago
Interesting. That doesn't seem particularly hard to implement, as you're right, passing around a flag to the diff code that says "this side always wins" seems easy enough.
I don't have time/itch to personally hack on this within the next ~weeks, but might get to it the next time I do a round of work on mirror.
Happy to review a PR if you take a crack at it. I can give some off-the-top-of-my-head ideas of what files/etc. to change if you're interested.
yeah, point me at it and I'll take a look
Here is where the core "local wins / remote wins" logic is at:
https://github.com/stephenh/mirror/blob/master/src/main/java/mirror/UpdateTreeDiff.java#L68
Maybe having some sort of enum like LatestOverride.NONE
, LOCAL
, REMOTE
, that then is then passed into the UpdateTreeDiff
somehow.
It'd have to be a command line around here:
https://github.com/stephenh/mirror/blob/master/src/main/java/mirror/Mirror.java#L144
E.g. call ./mirror client ... --latest-override=local
, and then passed to the server in the proto file:
https://github.com/stephenh/mirror/blob/master/src/main/proto/mirror.proto#L28
With an inversion, e.g. if the client is in LatestOverride.LOCAL
mode, then the server should be told to use LatestOverride.REMOTE
, so that it knows that it "looses" all newer decisions.
"LatestOverride" seems like an okay-ish name; could be something like "NewerOverride". Dunno, open to better names.
okay, looks straightforward enough. I'll try to get around to it this week 🙏
see #36
I have a slightly unusual usecase where I want to sync from my development box to a cloud-side server, and then from that server to a number of docker containers cloud-side. The hub-and-spoke pattern will work fine for me, but in this particular case, if I've deleted a file on my laptop while I was disconnected, I don't want the server to send it back to me if it (likewise if any of the containers happen to have it).
If I could specify sync directions then I could set
laptop -> server -> other clients
and be sure I never get unexpected files appearing on my box after I've deleted them.I suppose the main sticking point here might be that during the sync, if the laptop doesn't have the file the server should delete it, which is different/more complex logic than the current 'last write wins' strategy.