Repository navigation
lib/model: Check folder error before sync-waiting (fixes #6793) - #6847
Conversation
|
Probably just evolution. Maybe setState and setError should be combined. Either we are in a "doing something" or "waiting for something" state, when there implicitly can't be an error, or we are done with something and the outcome determines if we are now in an error state or not... |
calmh
left a comment
There was a problem hiding this comment.
This is probably fine, unless we want to improve it further.
Generally I think we have too many exit paths so it's not clear to me how/when a folder changes state back, hence the defer. Maybe the state and/or error setting should happen in just one (outermost) place and the various inner pieces just communicate by returning errors upwards. Or something.
|
I agree it could and should be improved, however I'd anyway like to get this fix in the way things work currently going. So when it gets improved it start from a sounder base. |
* main: (368 commits) build: We now target Go 1.14 lib/fs: Disable ioctl on ppc (fixes syncthing#6898) (syncthing#6901) gui, man, authors: Update docs, translations, and contributors lib/dialer: Try dialing without reuse in parallel (fixes syncthing#6892) (syncthing#6893) cmd/stcrashreceiver: Don't crash on nil err all: Remove need to restart syncthing (syncthing#6883) lib/db: Don't put truncated files (ref syncthing#6855, ref syncthing#6501) (syncthing#6888) lib/osutil: Check returned error instead of info (ref syncthing#6885) (syncthing#6887) gui, man, authors: Update docs, translations, and contributors lib/osutil: Preserve perms in AtomicWriter (fixes #tbd) (syncthing#6885) lib/fs: Fix WatchRename test for FreeBSD (fixes syncthing#6613) lib/fs: Unwrap mtimeFile, get fd the "correct" way (ref syncthing#6875) (syncthing#6877) lib/model: Don't close file early (fixes syncthing#6875) (syncthing#6876) lib/fs: Unwrap mtimeFile, get fd the "correct" way (ref syncthing#6875) (syncthing#6877) gui, man, authors: Update docs, translations, and contributors lib/fs: Fix WatchRename test for FreeBSD (fixes syncthing#6613) lib/model: Don't close file early (fixes syncthing#6875) (syncthing#6876) lib/db: Log context on panic (syncthing#6872) gui: Don't show pull order on SO folders (ref syncthing#6807) (syncthing#6871) lib/model: Check folder error before sync-waiting (fixes syncthing#6793) (syncthing#6847) ...
There's two related elements here: 1.
folder.pullshould notdefer f.setState(FolderIdle). The actual underlying pull already takes care of folder state (either error or idle). 2. For scanning and (real) pulling we always check folder health/error before setting status. We don't do the same for sync-waiting. This means an existing error gets "half-cleared": State changes to sync-waiting, but error remains (as errors are only touched bysetError). Thus when the actual puller callssetError, it sees the same error before and after and thus returns early without setting the folder state back to error. Regardless of this issue I believe it makes sense to check folder health before acquiring the iolimiter token to get the error notification to the user faster.I don't entirely get the separation of
setStateandsetErrorthough. GivensetErroris called withnil, it seems like one shouldn't callsetStatewhen an error is set/"active", but that's not enforced. If that's not the case andsetStateis meant to override errors, it doesn't do that (nos.err = nil). To me it would feel simpler and more robust ifsetStatedid clear previous error states. Does anyone have any insights into why things work as they do at the moment?