aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Frei <freisim93@gmail.com>2024-03-10 22:28:40 +0100
committerGitHub <noreply@github.com>2024-03-10 22:28:40 +0100
commit73cc5553b623dbbe71b75ddd0add9b89dca6714a (patch)
treec31a3c8ca94b2edc676393d04be707c4b131a13d
parent2ab2488274a2a5a857402fd65c949bddadbd7fad (diff)
downloadsyncthing-73cc5553b623dbbe71b75ddd0add9b89dca6714a.tar.gz
syncthing-73cc5553b623dbbe71b75ddd0add9b89dca6714a.zip
lib/model: Prevent infinite index sending loop (fixes #9407) (#9458)
Explanation of what/why in a code comment. Fixes https://github.com/syncthing/syncthing/issues/9407
-rw-r--r--lib/model/indexhandler.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/model/indexhandler.go b/lib/model/indexhandler.go
index 30b56c695..efa2754a9 100644
--- a/lib/model/indexhandler.go
+++ b/lib/model/indexhandler.go
@@ -295,12 +295,13 @@ func (s *indexHandler) sendIndexTo(ctx context.Context, fset *db.FileSet) error
err = batch.Flush()
- // True if there was nothing to be sent
- if f.Sequence == 0 {
- return err
- }
+ // Use the sequence of the snapshot we iterated as a starting point for the
+ // next run. Previously we used the sequence of the last file we sent,
+ // however it's possible that a higher sequence exists, just doesn't need to
+ // be sent (e.g. in a receive-only folder, when a local change was
+ // reverted). No point trying to send nothing again.
+ s.prevSequence = snap.Sequence(protocol.LocalDeviceID)
- s.prevSequence = f.Sequence
return err
}