Change progress emitter

1. Do not use cached value for BytesCompleted
2. Refactor JS a bit
3. Allow disabling progress emitter
This commit is contained in:
Audrius Butkevicius
2014-11-25 22:07:18 +00:00
parent c7d779fe88
commit ea17542e4b
4 changed files with 22 additions and 24 deletions

View File

@@ -145,7 +145,9 @@ func NewModel(cfg *config.ConfigWrapper, deviceName, clientName, clientVersion s
finder: files.NewBlockFinder(db, cfg),
progressEmitter: NewProgressEmitter(cfg),
}
go m.progressEmitter.Serve()
if cfg.Options().ProgressUpdateIntervalS > -1 {
go m.progressEmitter.Serve()
}
var timeout = 20 * 60 // seconds
if t := os.Getenv("STDEADLOCKTIMEOUT"); len(t) > 0 {

View File

@@ -120,10 +120,9 @@ func (t *ProgressEmitter) BytesCompleted(folder string) (bytes int64) {
t.mut.Lock()
defer t.mut.Unlock()
files, ok := t.last[folder]
if ok {
for _, s := range files {
bytes += s.BytesDone
for _, s := range t.registry {
if s.folder == folder {
bytes += s.Progress().BytesDone
}
}
if debug {