code: func (s *stateTracker) setState(newState folderState) {
  	if newState == FolderError {
  		panic("must use setError")
  	}
  
  	s.mut.Lock()
  	if newState != s.current {
  		/* This should hold later...
  		if s.current != FolderIdle && (newState == FolderScanning || newState == FolderSyncing) {
  			panic("illegal state transition " + s.current.String() + " -> " + newState.String())
  		}
  		*/
  
  		eventData := map[string]interface{}{
  			"folder": s.folderID,
  			"to":     newState.String(),
  			"from":   s.current.String(),
  		}
  
  		if !s.changed.IsZero() {
  			eventData["duration"] = time.Since(s.changed).Seconds()
  		}
  
  		s.current = newState
  		s.changed = time.Now()
  
  		events.Default.Log(events.StateChanged, eventData)
  	}
  	s.mut.Unlock()
  }
docs: // setState sets the new folder state, for states other than FolderError.