lib/model: Sort outgoing index updates by LocalVersion

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3411
This commit is contained in:
Jakob Borg
2016-07-21 17:21:15 +00:00
committed by Audrius Butkevicius
parent e1a4f81e50
commit 8ab6b60778
3 changed files with 361 additions and 0 deletions

View File

@@ -1194,6 +1194,9 @@ func sendIndexTo(initial bool, minLocalVer int64, conn protocol.Connection, fold
maxLocalVer := int64(0)
var err error
sorter := NewIndexSorter()
defer sorter.Close()
fs.WithHave(protocol.LocalDeviceID, func(fi db.FileIntf) bool {
f := fi.(protocol.FileInfo)
if f.LocalVersion <= minLocalVer {
@@ -1209,6 +1212,11 @@ func sendIndexTo(initial bool, minLocalVer int64, conn protocol.Connection, fold
return true
}
sorter.Append(f)
return true
})
sorter.Sorted(func(f protocol.FileInfo) bool {
if len(batch) == indexBatchSize || currentBatchSize > indexTargetSize {
if initial {
if err = conn.Index(folder, batch); err != nil {