- Run one FileWatcher on the client, and sync changes client to server
- Run one FileWatcher on the server, and sync changes server to client
- Bootstrap the process, for now with an rsync of server to client
- When a file changes, send path+time+data to other side
- State machine of the file on each side?
- Server-side should own the state machine of path/mtime/hash
- If no client-side connection, server-side can cache changes since last client connect
- When client connects, bring up to date
Need a state machine of the connection state:
- Initialize
- Get Server State
- If overflow goto 1
- Get Client State
- If overlfow goto 1
- Bring into sync
- Watch server
- If overflow goto 1
- watch client
- If overlfow goto 1
The steady-state (post initial sync) client side would be:
- One thread listening for file changes (or overflow)
- One thread listening for server changes
- Central logic that, on each incoming Update, decides what to do
Then:
- On change from server:
- Ensure server's mtime >= our mtime
- If so, write file
- If not, it's fine, we should have an incoming/outgoing Update to correct the server
- Ensure server's mtime >= our mtime
- On add/change from file system:
- Send file + mtime to server
Both sides should have:
- One thread for inotify (
FileWatcher
)- Writes to inbound queue
- grpc thread(s) listening stream
- Writes to inbound queue
- One thread diffing trees (
SyncLogic
)- Writes to outbound queue
- One thread putting updates on the wire