Skip to content

lib/model: Return paused summary instead of error on paused folders - #6272

Merged
calmh merged 1 commit into
syncthing:masterfrom
imsodin:model/summaryPausedErr
Jan 17, 2020
Merged

calmh merged 1 commit into
syncthing:masterfrom
imsodin:model/summaryPausedErr

Conversation

@imsodin

@imsodin imsodin commented Jan 16, 2020

Copy link
Copy Markdown
Member

See https://forum.syncthing.net/t/rest-db-status-returns-404-on-startup/14329

If the api starts while the folder is not yet running or generally when querying /rest/db/status for a an about to be started folder, we return a 404. Now it is treated the same as a paused folder, i.e. send a valid folder summary. However the comment was wrong: We can't get any info from db for a paused folder, nevertheless it's important to get valid entries with zero values, otherwise the UI blows up.

@calmh

calmh commented Jan 17, 2020 •

Copy link
Copy Markdown
Member

This will leave some other attributes in odd states though, like the "State" field which will become entirely blank and a 0001-01-01 state changed date because there is no runner and

syncthing/lib/model/model.go

Lines 2304 to 2316 in e782bab

func (m *model) State(folder string) (string, time.Time, error) {
m.fmut.RLock()
runner, ok := m.folderRunners[folder]
m.fmut.RUnlock()
if !ok {
// The returned error should be an actual folder error, so returning
// errors.New("does not exist") or similar here would be
// inappropriate.
return "", time.Time{}, nil
}
state, changed, err := runner.getState()
return state.String(), changed, err
}

@imsodin

imsodin commented Jan 17, 2020

Copy link
Copy Markdown
Member Author

That's the same thing that happens today when the folder is paused. I agree it's not ideal, but it was the most minimal and consistent (aka leave the API behaviour mostly untouched) fix I came up with. One alternative I thought about was setting the state field to paused: That's inconsistent with it's previous use, where it is about the state a running folder is in. Also is it state, or error and we don't have a stateChanged time in either case. Another introducing another boolean field running and when the folder is not running, send a summary with just that field set to false. That however breaks our web UI by not sending zero values for the local/global item fields. It's definitely an API change and would require tweaking the UI or defining a minimal empty summary, that gets sent along even if !running. (Or even more radical: Don't remove paused folders from the model, only stop them, then the folder summary service still has access to db and can correctly report the state at the time of pausing).

@calmh

calmh commented Jan 17, 2020

Copy link
Copy Markdown
Member

Oh, right, already happens... Huh. This is not ideal imho, but a separate issue then.

@calmh
calmh merged commit 39891cd into syncthing:master Jan 17, 2020
@imsodin
imsodin deleted the model/summaryPausedErr branch January 17, 2020 08:32
calmh added a commit to calmh/syncthing that referenced this pull request Jan 21, 2020
* master:
  lib/model: Handle progress emitter zero interval (fixes syncthing#6281) (syncthing#6282)
  build(deps): bump github.com/pkg/errors from 0.9.0 to 0.9.1 (syncthing#6279)
  cmd/syncthing: Always use monitor process (fixes syncthing#4774, fixes syncthing#5786) (syncthing#6278)
  lib/syncthing: Wait for actual termination on Stop() (syncthing#6277)
  lib/model: Remove legacy handling of symlinks (syncthing#6276)
  lib/model: Return paused summary instead of error on paused folders (syncthing#6272)
  lib/config: Add some info to the folder marker missing (ref syncthing#5207) (syncthing#6270)
@calmh calmh added this to the v1.4.0 milestone Jan 24, 2020
calmh added a commit to calmh/syncthing that referenced this pull request Jan 30, 2020
* master: (28 commits)
  gui, man, authors: Update docs, translations, and contributors
  lib/config, lib/model: Limit concurrent pulls (fixes syncthing#5914) (syncthing#6290)
  lib/db: Fixup last commit with better key name
  lib/db: Configurable block GC time (syncthing#6295)
  lib/db: Deduplicate block lists in database (fixes syncthing#5898) (syncthing#6283)
  lib/relays: Fix incorrect timeout, bring back logging (ref syncthing#6289) (syncthing#6291)
  gui, man, authors: Update docs, translations, and contributors
  all: Transactionalize db.FileSet (fixes syncthing#5952) (syncthing#6239)
  lib/model: Handle progress emitter zero interval (fixes syncthing#6281) (syncthing#6282)
  build(deps): bump github.com/pkg/errors from 0.9.0 to 0.9.1 (syncthing#6279)
  cmd/syncthing: Always use monitor process (fixes syncthing#4774, fixes syncthing#5786) (syncthing#6278)
  lib/syncthing: Wait for actual termination on Stop() (syncthing#6277)
  lib/model: Remove legacy handling of symlinks (syncthing#6276)
  lib/model: Return paused summary instead of error on paused folders (syncthing#6272)
  lib/config: Add some info to the folder marker missing (ref syncthing#5207) (syncthing#6270)
  assets, gui: Losslessly compress all JPG, PNG, and PDF images (syncthing#6265)
  cmd/strelaypoolsrv: Serve gzip compressed responses
  gui, man, authors: Update docs, translations, and contributors
  gui, man, authors: Update docs, translations, and contributors
  build: go mod tidy
  ...
calmh added a commit to calmh/syncthing that referenced this pull request Jan 30, 2020
* master: (32 commits)
  gui, man, authors: Update docs, translations, and contributors
  lib/config, lib/model: Limit concurrent pulls (fixes syncthing#5914) (syncthing#6290)
  lib/db: Fixup last commit with better key name
  lib/db: Configurable block GC time (syncthing#6295)
  lib/db: Deduplicate block lists in database (fixes syncthing#5898) (syncthing#6283)
  lib/relays: Fix incorrect timeout, bring back logging (ref syncthing#6289) (syncthing#6291)
  gui, man, authors: Update docs, translations, and contributors
  all: Transactionalize db.FileSet (fixes syncthing#5952) (syncthing#6239)
  lib/model: Handle progress emitter zero interval (fixes syncthing#6281) (syncthing#6282)
  build(deps): bump github.com/pkg/errors from 0.9.0 to 0.9.1 (syncthing#6279)
  cmd/syncthing: Always use monitor process (fixes syncthing#4774, fixes syncthing#5786) (syncthing#6278)
  lib/syncthing: Wait for actual termination on Stop() (syncthing#6277)
  lib/model: Remove legacy handling of symlinks (syncthing#6276)
  lib/model: Return paused summary instead of error on paused folders (syncthing#6272)
  lib/config: Add some info to the folder marker missing (ref syncthing#5207) (syncthing#6270)
  assets, gui: Losslessly compress all JPG, PNG, and PDF images (syncthing#6265)
  cmd/strelaypoolsrv: Serve gzip compressed responses
  gui, man, authors: Update docs, translations, and contributors
  gui, man, authors: Update docs, translations, and contributors
  build: go mod tidy
  ...
imsodin added a commit to imsodin/syncthing that referenced this pull request Feb 11, 2020
imsodin added a commit to imsodin/syncthing that referenced this pull request Feb 11, 2020
imsodin added a commit to imsodin/syncthing that referenced this pull request Feb 11, 2020
imsodin added a commit to imsodin/syncthing that referenced this pull request Feb 11, 2020
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jan 17, 2021
@syncthing syncthing locked and limited conversation to collaborators Jan 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants