Repository navigation
lib/model: Skip paused folders in aggregated completion loop (fixes #8219) - #8220
Conversation
Locally paused folders will fail on checkFolderRunningLocked() and therefore abort the loop. Avoid this by skipping paused folders directly.
| // We want completion for all (shared) folders as an aggregate. | ||
| var comp FolderCompletion | ||
| for _, fcfg := range m.cfg.FolderList() { | ||
| if fcfg.Paused { |
There was a problem hiding this comment.
There's a race condition here in that the folder might not be paused when we look now, but it might be when we calculate the completion. I suggest an errors.Is(err, ErrFolderPaused) check on the returned error in the loop instead
There was a problem hiding this comment.
Maybe even a more generic error catch is needed: There might also be a race removing a folder. An alternative would be to refactor to do this under an m.fmut.RLock() and use m.folderCfgs, instead of every m.folderCompletion acquiring that lock individually - that's however a much larger and more delicate change (locks), so I'd probably go with error checking too :)
| // We want completion for all (shared) folders as an aggregate. | ||
| var comp FolderCompletion | ||
| for _, fcfg := range m.cfg.FolderList() { | ||
| if fcfg.Paused { |
There was a problem hiding this comment.
There's a race condition here in that the folder might not be paused when we look now, but it might be when we calculate the completion. I suggest an errors.Is(err, ErrFolderPaused) check on the returned error in the loop instead
* main: (121 commits) gui, api: Show internal config and state paths (fixes syncthing#8323) (syncthing#8324) build(deps): bump github.com/go-ldap/ldap/v3 from 3.4.1 to 3.4.4 (syncthing#8475) build: bump actions/setup-go from 2.2.0 to 3.2.1 (syncthing#8492) build: Let dependabot suggest updates to GitHub actions (syncthing#8490) update: Go version in update-docs-translations action (syncthing#8489) gui, man, authors: Update docs, translations, and contributors cmd/syncthing: Refactor CLI code to allow passing CLI arguments via function parameter (syncthing#8485) build: Update quic-go for Go 1.19 (syncthing#8483) lib/ur: Properly initialize map in failure data (fixes syncthing#8479) (syncthing#8480) lib/ur: Properly initialize map in failure data (fixes syncthing#8479) gui, man, authors: Update docs, translations, and contributors docs: Clarify docker network mode limitations (syncthing#8472) lib/config: Use net.JoinHostPort instead of string manipulation (syncthing#8470) lib/api: Fix inverted logic in string comparison lib/model: Use bytes.Equal instead of converting to string (syncthing#8469) all: Add build constants for runtime.GOOS comparisons (syncthing#8442) cmd/strelaysrv: Fix superfluous else statements (syncthing#8468) all: Fix nested `if` with `else if` (syncthing#8467) all: Unused errors lib/fs: Consolidate append in test ...
* main: lib/model: Skip paused folders in aggregated completion loop (fixes syncthing#8219) (syncthing#8220) gui: Remove unused strings from translations (syncthing#8288)
* main: (256 commits) cmd/syncthing: Use os.executable in monitor, only fallback to PATH (syncthing#8502) all: Modernize error wrapping (syncthing#8491) gui, man, authors: Update docs, translations, and contributors cmd/syncthing: Work around binary in current dir restriction (fixes syncthing#8499) (syncthing#8500) lib/fs: Cache user lookups (syncthing#8496) all: Make scanning ownership opt-in (syncthing#8497) lib/model: Skip paused folders in aggregated completion loop (fixes syncthing#8219) (syncthing#8220) gui: Remove unused strings from translations (syncthing#8288) gui, api: Show internal config and state paths (fixes syncthing#8323) (syncthing#8324) build(deps): bump github.com/go-ldap/ldap/v3 from 3.4.1 to 3.4.4 (syncthing#8475) build: bump actions/setup-go from 2.2.0 to 3.2.1 (syncthing#8492) build: Let dependabot suggest updates to GitHub actions (syncthing#8490) update: Go version in update-docs-translations action (syncthing#8489) gui, man, authors: Update docs, translations, and contributors cmd/syncthing: Refactor CLI code to allow passing CLI arguments via function parameter (syncthing#8485) build: Update quic-go for Go 1.19 (syncthing#8483) lib/ur: Properly initialize map in failure data (fixes syncthing#8479) (syncthing#8480) lib/ur: Properly initialize map in failure data (fixes syncthing#8479) gui, man, authors: Update docs, translations, and contributors docs: Clarify docker network mode limitations (syncthing#8472) ...
Locally paused folders will fail on checkFolderRunningLocked() and therefore abort the loop. Avoid this by skipping paused folders directly.
Testing
Test suite passes. Manually verified API response not giving an error with a paused folder and the completion numbers being reduced by the appropriate amount.