lib, gui: Default ignores for new folders (fixes #7428) (#7530)

This commit is contained in:
Simon Frei
2022-01-13 23:38:21 +01:00
committed by GitHub
parent 40bb52fdd8
commit 21d04b895a
17 changed files with 718 additions and 218 deletions
+22
View File
@@ -229,6 +229,28 @@ func (c *configMuxBuilder) registerDefaultDevice(path string) {
})
}
func (c *configMuxBuilder) registerDefaultIgnores(path string) {
c.HandlerFunc(http.MethodGet, path, func(w http.ResponseWriter, _ *http.Request) {
sendJSON(w, c.cfg.DefaultIgnores())
})
c.HandlerFunc(http.MethodPut, path, func(w http.ResponseWriter, r *http.Request) {
var ignores config.Ignores
if err := unmarshalTo(r.Body, &ignores); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
waiter, err := c.cfg.Modify(func(cfg *config.Configuration) {
cfg.Defaults.Ignores = ignores
})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
c.finish(w, waiter)
})
}
func (c *configMuxBuilder) registerOptions(path string) {
c.HandlerFunc(http.MethodGet, path, func(w http.ResponseWriter, _ *http.Request) {
sendJSON(w, c.cfg.Options())