Repository: syncthing/syncthing
File: lib/model/model.go (Go)

Code before:
	runner, _ := m.folderRunners.Get(to.ID)
	m.indexHandlers.Each(func(_ protocol.DeviceID, r *indexHandlerRegistry) error {
		r.RegisterFolderState(to, fset, runner)
		return nil
	})

	var infoMsg string
	switch {
	case to.Paused:
		infoMsg = "Paused"
	case from.Paused:
		infoMsg = "Unpaused"
	default:
		infoMsg = "Restarted"
	}
	l.Infof("%v folder %v (%v)", infoMsg, to.Description(), to.Type)

	return nil
}

func (m *model) newFolder(cfg config.FolderConfiguration, cacheIgnoredFiles bool) error {
	m.mut.Lock()
	defer m.mut.Unlock()

	// Creating the fileset can take a long time (metadata calculation), but
	// nevertheless should happen inside the lock.
	fset, err := db.NewFileSet(cfg.ID, m.db)
	if err != nil {
		return fmt.Errorf("adding %v: %w", cfg.Description(), err)
	}

	m.addAndStartFolderLocked(cfg, fset, cacheIgnoredFiles)

	// Cluster configs might be received and processed before reaching this
	// point, i.e. before the folder is started. If that's the case, start
	// index senders here.
	m.indexHandlers.Each(func(_ protocol.DeviceID, r *indexHandlerRegistry) error {
		runner, _ := m.folderRunners.Get(cfg.ID)
		r.RegisterFolderState(cfg, fset, runner)
		return nil
	})

	return nil
}

func (m *model) UsageReportingStats(report *contract.Report, version int, preview bool) {
	if version >= 3 {
		// Block stats
		blockStatsMut.Lock()
		for k, v := range blockStats {
			switch k {

Review comment (suggestion):
Maybe worth referencing the other place here (and potentially vice-versa), just so if we decide to change it once again, we at least increase the chance that we consider both places :) 

```suggestion
	// Creating the fileset can take a long time (metadata calculation), but
	// nevertheless should happen inside the lock (same as when restarting
	// a folder).
```

Code after:
	runner, _ := m.folderRunners.Get(to.ID)
	m.indexHandlers.Each(func(_ protocol.DeviceID, r *indexHandlerRegistry) error {
		r.RegisterFolderState(to, fset, runner)
		return nil
	})

	var infoMsg string
	switch {
	case to.Paused:
		infoMsg = "Paused"
	case from.Paused:
		infoMsg = "Unpaused"
	default:
		infoMsg = "Restarted"
	}
	l.Infof("%v folder %v (%v)", infoMsg, to.Description(), to.Type)

	return nil
}

func (m *model) newFolder(cfg config.FolderConfiguration, cacheIgnoredFiles bool) error {
	m.mut.Lock()
	defer m.mut.Unlock()

	// Creating the fileset can take a long time (metadata calculation), but
	// nevertheless should happen inside the lock (same as when restarting
	// a folder).
	fset, err := db.NewFileSet(cfg.ID, m.db)
	if err != nil {
		return fmt.Errorf("adding %v: %w", cfg.Description(), err)
	}

	m.addAndStartFolderLocked(cfg, fset, cacheIgnoredFiles)

	// Cluster configs might be received and processed before reaching this
	// point, i.e. before the folder is started. If that's the case, start
	// index senders here.
	m.indexHandlers.Each(func(_ protocol.DeviceID, r *indexHandlerRegistry) error {
		runner, _ := m.folderRunners.Get(cfg.ID)
		r.RegisterFolderState(cfg, fset, runner)
		return nil
	})

	return nil
}

func (m *model) UsageReportingStats(report *contract.Report, version int, preview bool) {
	if version >= 3 {
		// Block stats
		blockStatsMut.Lock()
		for k, v := range blockStats {