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

Method setWatchError

lib/model/folder.go:1140–1165  ·  view source on GitHub ↗

setWatchError sets the current error state of the watch and should be called regardless of whether err is nil or not.

(err error, nextTryIn time.Duration)

Source from the content-addressed store, hash-verified

1138// setWatchError sets the current error state of the watch and should be called
1139// regardless of whether err is nil or not.
1140func (f *folder) setWatchError(err error, nextTryIn time.Duration) {
1141 f.watchMut.Lock()
1142 prevErr := f.watchErr
1143 f.watchErr = err
1144 f.watchMut.Unlock()
1145 if err != prevErr { //nolint:errorlint
1146 data := map[string]interface{}{
1147 "folder": f.ID,
1148 }
1149 if prevErr != nil {
1150 data["from"] = prevErr.Error()
1151 }
1152 if err != nil {
1153 data["to"] = err.Error()
1154 }
1155 f.evLogger.Log(events.FolderWatchStateChanged, data)
1156 }
1157 if err == nil {
1158 return
1159 }
1160 if prevErr != err { //nolint:errorlint
1161 f.sl.Warn("Failed to start filesystem watcher", slog.String("wait", nextTryIn.String()), slogutil.Error(err))
1162 } else {
1163 f.sl.Debug("Failed to start filesystem watcher", slog.String("wait", nextTryIn.String()), slogutil.Error(err))
1164 }
1165}
1166
1167// scanOnWatchErr schedules a full scan immediately if an error occurred while watching.
1168func (f *folder) scanOnWatchErr() {

Callers 2

stopWatchMethod · 0.95
monitorWatchMethod · 0.95

Calls 5

ErrorFunction · 0.92
UnlockMethod · 0.80
ErrorMethod · 0.65
LogMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected