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)
| 1138 | // setWatchError sets the current error state of the watch and should be called |
| 1139 | // regardless of whether err is nil or not. |
| 1140 | func (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. |
| 1168 | func (f *folder) scanOnWatchErr() { |