MCPcopy Index your code
hub / github.com/syncthing/syncthing / setError

Method setError

lib/model/folderstate.go:151–187  ·  view source on GitHub ↗

setError sets the folder state to FolderError with the specified error or to FolderIdle if the error is nil

(err error)

Source from the content-addressed store, hash-verified

149// setError sets the folder state to FolderError with the specified error or
150// to FolderIdle if the error is nil
151func (s *stateTracker) setError(err error) {
152 s.mut.Lock()
153 defer s.mut.Unlock()
154
155 defer func() {
156 metricFolderState.WithLabelValues(s.folderID).Set(float64(s.current))
157 }()
158
159 eventData := map[string]interface{}{
160 "folder": s.folderID,
161 "from": s.current.String(),
162 }
163
164 if err != nil && s.current != FolderError {
165 slog.Warn("Folder is in error state", slog.String("folder", s.folderID), slogutil.Error(err))
166 } else if err == nil && s.current == FolderError {
167 slog.Info("Folder error state was cleared", slog.String("folder", s.folderID))
168 }
169
170 if err != nil {
171 eventData["error"] = err.Error()
172 s.current = FolderError
173 } else {
174 s.current = FolderIdle
175 }
176
177 eventData["to"] = s.current.String()
178
179 if !s.changed.IsZero() {
180 eventData["duration"] = time.Since(s.changed).Seconds()
181 }
182
183 s.err = err
184 s.changed = time.Now().Truncate(time.Second)
185
186 s.evLogger.Log(events.StateChanged, eventData)
187}

Callers

nothing calls this directly

Calls 9

ErrorFunction · 0.92
UnlockMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.65
SinceMethod · 0.65
TruncateMethod · 0.65
NowMethod · 0.65
LogMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected