mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Only keep track of version (not modified) for sent index
This commit is contained in:
parent
21b699826d
commit
964c903a68
@ -81,7 +81,7 @@ type rawConnection struct {
|
|||||||
xw *xdr.Writer
|
xw *xdr.Writer
|
||||||
wmut sync.Mutex
|
wmut sync.Mutex
|
||||||
|
|
||||||
indexSent map[string]map[string][2]int64
|
indexSent map[string]map[string]uint64
|
||||||
awaiting []chan asyncResult
|
awaiting []chan asyncResult
|
||||||
imut sync.Mutex
|
imut sync.Mutex
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ func NewConnection(nodeID string, reader io.Reader, writer io.Writer, receiver M
|
|||||||
wb: wb,
|
wb: wb,
|
||||||
xw: xdr.NewWriter(wb),
|
xw: xdr.NewWriter(wb),
|
||||||
awaiting: make([]chan asyncResult, 0x1000),
|
awaiting: make([]chan asyncResult, 0x1000),
|
||||||
indexSent: make(map[string]map[string][2]int64),
|
indexSent: make(map[string]map[string]uint64),
|
||||||
outbox: make(chan []encodable),
|
outbox: make(chan []encodable),
|
||||||
nextID: make(chan int),
|
nextID: make(chan int),
|
||||||
closed: make(chan struct{}),
|
closed: make(chan struct{}),
|
||||||
@ -149,18 +149,18 @@ func (c *rawConnection) Index(repo string, idx []FileInfo) {
|
|||||||
// This is the first time we send an index.
|
// This is the first time we send an index.
|
||||||
msgType = messageTypeIndex
|
msgType = messageTypeIndex
|
||||||
|
|
||||||
c.indexSent[repo] = make(map[string][2]int64)
|
c.indexSent[repo] = make(map[string]uint64)
|
||||||
for _, f := range idx {
|
for _, f := range idx {
|
||||||
c.indexSent[repo][f.Name] = [2]int64{f.Modified, int64(f.Version)}
|
c.indexSent[repo][f.Name] = f.Version
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We have sent one full index. Only send updates now.
|
// We have sent one full index. Only send updates now.
|
||||||
msgType = messageTypeIndexUpdate
|
msgType = messageTypeIndexUpdate
|
||||||
var diff []FileInfo
|
var diff []FileInfo
|
||||||
for _, f := range idx {
|
for _, f := range idx {
|
||||||
if vs, ok := c.indexSent[repo][f.Name]; !ok || f.Modified != vs[0] || int64(f.Version) != vs[1] {
|
if vs, ok := c.indexSent[repo][f.Name]; !ok || f.Version != vs {
|
||||||
diff = append(diff, f)
|
diff = append(diff, f)
|
||||||
c.indexSent[repo][f.Name] = [2]int64{f.Modified, int64(f.Version)}
|
c.indexSent[repo][f.Name] = f.Version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idx = diff
|
idx = diff
|
||||||
|
Loading…
Reference in New Issue
Block a user