-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/model: Support removing paused folders (fixes #4357) #4358
Conversation
lib/model/model.go
Outdated
} | ||
if !ok { | ||
// Folder does not exist... Weird... | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should never happen and thus panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When/if we add HTTP DELETE /folders/xyz
API, this would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that result in a returned error? I think there are some endpoints presently that check whether a folder is present before doing anything.
Test: func TestRemovePausedFolder(t *testing.T) {
// issue 4357
db := db.OpenMemory()
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
defCfg := defaultFolderConfig.Copy()
m.AddFolder(defCfg)
m.StartFolder("default")
m.ServeBackground()
defer m.Stop()
oldCfg := m.cfg.RawCopy()
newCfg := oldCfg.Copy()
newCfg.Folders[0].Paused = true
m.CommitConfiguration(oldCfg, newCfg)
m.RemoveFolder("default")
m.fmut.Lock()
if _, ok := m.folderCfgs["default"]; ok {
t.Error("Paused folder was not removed")
}
m.fmut.Unlock()
} |
I think the test is not very useful. CommitConfig does the removal from folderCfgs, not the m.RemoveFolder in this case. |
Yet let me add a different one, and add the panic I guess. |
It panics as in the referenced issue, so I guess it does what it is supposed to: reproduce it - what am I missing? |
aa36d3e
to
8f6dddf
Compare
My point was that this check was too late:
Anyways, updated and added a test case. |
Ups, wrong bot. @st-release lgtm |
@st-review lgtm |
@imsodin: Noted! Need another LGTM or explicit merge command. |
@st-review lgtm |
👌 Merged as e85ce7c. Thanks, @AudriusButkevicius! |
Tested manually.