Skip to content
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

Closed

Conversation

AudriusButkevicius
Copy link
Member

Tested manually.

}
if !ok {
// Folder does not exist... Weird...
return
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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.

@imsodin
Copy link
Member

imsodin commented Sep 9, 2017

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()
}

@AudriusButkevicius
Copy link
Member Author

I think the test is not very useful. CommitConfig does the removal from folderCfgs, not the m.RemoveFolder in this case.

@AudriusButkevicius
Copy link
Member Author

Yet let me add a different one, and add the panic I guess.

@imsodin
Copy link
Member

imsodin commented Sep 9, 2017

I think the test is not very useful. CommitConfig does the removal from folderCfgs, not the m.RemoveFolder in this case.

It panics as in the referenced issue, so I guess it does what it is supposed to: reproduce it - what am I missing?

@AudriusButkevicius
Copy link
Member Author

My point was that this check was too late:

if _, ok := m.folderCfgs["default"]; ok {
	t.Error("Paused folder was not removed")
}

Anyways, updated and added a test case.

@imsodin
Copy link
Member

imsodin commented Sep 9, 2017

Ups, wrong bot.

@st-release lgtm

@imsodin
Copy link
Member

imsodin commented Sep 9, 2017

@st-review lgtm

@st-review
Copy link

@imsodin: Noted! Need another LGTM or explicit merge command.

@calmh
Copy link
Member

calmh commented Sep 9, 2017

@st-review lgtm

@st-review
Copy link

👌 Merged as e85ce7c. Thanks, @AudriusButkevicius!

@st-review st-review closed this Sep 9, 2017
st-review pushed a commit that referenced this pull request Sep 9, 2017
GitHub-Pull-Request: #4358
LGTM: imsodin, calmh
@AudriusButkevicius AudriusButkevicius deleted the delpause branch September 9, 2017 15:15
@st-review st-review added the pr-merged Legacy label used in the past for pull requests merged to the main tree label Jan 15, 2018
@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 Sep 10, 2018
@syncthing syncthing locked and limited conversation to collaborators Sep 10, 2018
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 pr-merged Legacy label used in the past for pull requests merged to the main tree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants