Pārlūkot izejas kodu

lib/scanner: Don't stop byte counter ticks before scan is done

Jakob Borg 8 gadi atpakaļ
vecāks
revīzija
2ebd6ad77f
2 mainītis faili ar 4 papildinājumiem un 3 dzēšanām
  1. 1 1
      cmd/syncthing/verboseservice.go
  2. 3 2
      lib/scanner/walk.go

+ 1 - 1
cmd/syncthing/verboseservice.go

@@ -154,7 +154,7 @@ func (s *verboseService) formatEvent(ev events.Event) string {
 		if total > 0 {
 			pct = 100 * current / total
 		}
-		return fmt.Sprintf("Scanning folder %q, %d%% done (%.01f MB/s)", folder, pct, rate)
+		return fmt.Sprintf("Scanning folder %q, %d%% done (%.01f MiB/s)", folder, pct, rate)
 
 	case events.DevicePaused:
 		data := ev.Data.(map[string]string)

+ 3 - 2
lib/scanner/walk.go

@@ -169,13 +169,14 @@ func (w *walker) walk() (chan protocol.FileInfo, error) {
 		realToHashChan := make(chan protocol.FileInfo)
 		done := make(chan struct{})
 		progress := newByteCounter()
-		defer progress.Close()
 
 		newParallelHasher(w.Dir, w.BlockSize, w.Hashers, finishedChan, realToHashChan, progress, done, w.Cancel)
 
 		// A routine which actually emits the FolderScanProgress events
 		// every w.ProgressTicker ticks, until the hasher routines terminate.
 		go func() {
+			defer progress.Close()
+
 			for {
 				select {
 				case <-done:
@@ -185,7 +186,7 @@ func (w *walker) walk() (chan protocol.FileInfo, error) {
 				case <-ticker.C:
 					current := progress.Total()
 					rate := progress.Rate()
-					l.Debugf("Walk %s %s current progress %d/%d at %.01f MB/s (%d%%)", w.Dir, w.Subs, current, total, rate/1024/1024, current*100/total)
+					l.Debugf("Walk %s %s current progress %d/%d at %.01f MiB/s (%d%%)", w.Dir, w.Subs, current, total, rate/1024/1024, current*100/total)
 					events.Default.Log(events.FolderScanProgress, map[string]interface{}{
 						"folder":  w.Folder,
 						"current": current,