Repository navigation
lib: Return error from db.FileSet.Snapshot (fixes #7419, ref #5907) - #7424
Conversation
| if !f.pull() && f.pullPause < 60*f.pullBasePause() { | ||
| var success bool | ||
| success, err = f.pull() | ||
| if err == nil && success && f.pullPause < 60*f.pullBasePause() { |
There was a problem hiding this comment.
This inverts the condition on success -- we shouldn't back off when pull was successfull
| return m.availabilityWithInfo(cfg, snap, file, block), nil | ||
| } | ||
|
|
||
| func (m *model) availabilityWithInfo(cfg config.FolderConfiguration, snap *db.Snapshot, file protocol.FileInfo, block protocol.BlockInfo) []Availability { |
There was a problem hiding this comment.
...WithSnapshot seems more specific (or maybe even InSnapshot), or is there some other info we're looking for here?
There was a problem hiding this comment.
The unspecific "info" qualifier refers to already having the folder config and snapshot instead of needing to get them from the model, and WithConfigAndSnapshot is a mouthful.
There was a problem hiding this comment.
Well... I'd still go with something like snapshotAvailability and skip mentioning the config, at least it says more that it acts on a point in time than just "with info" which is sort of saying nothing. :)
| if success { | ||
| return true | ||
| if success && err != nil { | ||
| return true, nil |
There was a problem hiding this comment.
Shouldn't this be success && err == nil?
| if err := f.ioLimiter.takeWithContext(f.ctx, 1); err != nil { | ||
| f.setError(err) | ||
| return true | ||
| return true, err |
There was a problem hiding this comment.
This is the only instance of true + non-nil error being returned. Isn't it easier to drop the bool return value and check for timeout/context canceled in the retrying logic?
There was a problem hiding this comment.
Also in the end: A pull can result in no success (files couldn't be synced) without an error.
There was a problem hiding this comment.
Oh right, in line 226. Too bad.
* main: build: Update notify (syncthing#7444) next-gen-gui: Add button to restore default theme (syncthing#7433) lib/protocol: Optimize FileKey (syncthing#7440) cmd/syncthing, etc: Consistent failure restart backoff (syncthing#7439) lib: Return error from db.FileSet.Snapshot (fixes syncthing#7419, ref syncthing#5907) (syncthing#7424)
Purpose
Another step towards better database error handling (#5907), fixing #7419: Now
db.FileSet.Snapshotreturns an error instead of panicking.Most of the diff is boilerplate of adding error returns all over the place. One larger change regards folder error handling: Previously we did not bubble errors consistently (as in already existing errors unrelated to this PR). Now we do need errors in
Serveto shut the service down in case of fatal errors. I thus opted to bubble "folder-level" errors (as opposed to item level errors, e.g. errors scanning/pulling an item) up to the main loop in the service. That means the folder state is set with any error that reaches that point and isn't fatal.Testing
Existing unit tests pass and the UI still comes up - haven't done any manual testing beyond that.