mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
Send index immediately on local change
This commit is contained in:
parent
bbe1de3119
commit
fa922d7792
@ -1000,13 +1000,25 @@ func sendIndexes(conn protocol.Connection, folder string, fs *db.FileSet, ignore
|
|||||||
|
|
||||||
minLocalVer, err := sendIndexTo(true, 0, conn, folder, fs, ignores)
|
minLocalVer, err := sendIndexTo(true, 0, conn, folder, fs, ignores)
|
||||||
|
|
||||||
|
sub := events.Default.Subscribe(events.LocalIndexUpdated)
|
||||||
|
defer events.Default.Unsubscribe(sub)
|
||||||
|
|
||||||
for err == nil {
|
for err == nil {
|
||||||
time.Sleep(5 * time.Second)
|
// While we have sent a localVersion at least equal to the one
|
||||||
|
// currently in the database, wait for the local index to update. The
|
||||||
|
// local index may update for other folders than the one we are
|
||||||
|
// sending for.
|
||||||
if fs.LocalVersion(protocol.LocalDeviceID) <= minLocalVer {
|
if fs.LocalVersion(protocol.LocalDeviceID) <= minLocalVer {
|
||||||
|
sub.Poll(time.Minute)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
minLocalVer, err = sendIndexTo(false, minLocalVer, conn, folder, fs, ignores)
|
minLocalVer, err = sendIndexTo(false, minLocalVer, conn, folder, fs, ignores)
|
||||||
|
|
||||||
|
// Wait a short amount of time before entering the next loop. If there
|
||||||
|
// are continous changes happening to the local index, this gives us
|
||||||
|
// time to batch them up a little.
|
||||||
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
|
Loading…
Reference in New Issue
Block a user