aboutsummaryrefslogtreecommitdiff
path: root/doc/design/assistant/syncing.mdwn
blob: 8173457c552c741fe6c070e2713267543c13dc55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Once files are added (or removed or moved), need to send those changes to
all the other git clones, at both the git level and the key/value level.

## git syncing

1. Can use `git annex sync`, which already handles bidirectional syncing.
   When a change is committed, launch the part of `git annex sync` that pushes
   out changes. **done**; changes are pushed out to all remotes in parallel
1. Watch `.git/refs/remotes/` for changes (which would be pushed in from
   another node via `git annex sync`), and run the part of `git annex sync`
   that merges in received changes, and follow it by the part that pushes out
   changes (sending them to any other remotes).
   [The watching can be done with the existing inotify code! This avoids needing
   any special mechanism to notify a remote that it's been synced to.]  
   **done**
1. Periodically retry pushes that failed. Also, detect if a push failed
   due to not being up-to-date, pull, and repush.
2. Use a git merge driver that adds both conflicting files,
   so conflicts never break a sync.
3. Investigate the XMPP approach like dvcs-autosync does, or other ways of
   signaling a change out of band.
4. Add a hook, so when there's a change to sync, a program can be run
   and do its own signaling.

## data syncing

There are two parts to data syncing. First, map the network and second,
decide what to sync when.

Mapping the network can reuse code in `git annex map`. Once the map is
built, we want to find paths through the network that reach all nodes
eventually, with the least cost. This is a minimum spanning tree problem,
except with a directed graph, so really a Arborescence problem.

With the map, we can determine which nodes to push new content to. Then we
need to control those data transfers, sending to the cheapest nodes first,
and with appropriate rate limiting and control facilities.

This probably will need lots of refinements to get working well.

## other considerations

It would be nice if, when a USB drive is connected,
syncing starts automatically.

This assumes the network is connected. It's often not, so the
[[cloud]] needs to be used to bridge between LANs.