浏览代码

lib/model: Add minumum interval for progress emitter (fixes #3517)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3518
Audrius Butkevicius 9 年之前
父节点
当前提交
6ec4fbc82b
共有 2 个文件被更改,包括 4 次插入0 次删除
  1. 3 0
      lib/model/progressemitter.go
  2. 1 0
      lib/model/progressemitter_test.go

+ 3 - 0
lib/model/progressemitter.go

@@ -190,6 +190,9 @@ func (t *ProgressEmitter) CommitConfiguration(from, to config.Configuration) boo
 	defer t.mut.Unlock()
 	defer t.mut.Unlock()
 
 
 	t.interval = time.Duration(to.Options.ProgressUpdateIntervalS) * time.Second
 	t.interval = time.Duration(to.Options.ProgressUpdateIntervalS) * time.Second
+	if t.interval < time.Second {
+		t.interval = time.Second
+	}
 	t.minBlocks = to.Options.TempIndexMinBlocks
 	t.minBlocks = to.Options.TempIndexMinBlocks
 	l.Debugln("progress emitter: updated interval", t.interval)
 	l.Debugln("progress emitter: updated interval", t.interval)
 
 

+ 1 - 0
lib/model/progressemitter_test.go

@@ -60,6 +60,7 @@ func TestProgressEmitter(t *testing.T) {
 
 
 	p := NewProgressEmitter(c)
 	p := NewProgressEmitter(c)
 	go p.Serve()
 	go p.Serve()
+	p.interval = 0
 
 
 	expectTimeout(w, t)
 	expectTimeout(w, t)