Add and remove torrents from web interface ()

This commit is contained in:
Antonio Navarro Perez 2021-11-16 13:13:58 +01:00 committed by GitHub
parent 02842b1917
commit 2f18213660
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 996 additions and 1170 deletions

View file

@ -15,8 +15,7 @@ type EventFunc func(event string)
type ReloadFunc func(*Root, EventFunc) error
type Handler struct {
p string
reloadFunc ReloadFunc
p string
}
func NewHandler(path string) *Handler {
@ -71,27 +70,6 @@ func (c *Handler) Get() (*Root, error) {
return conf, nil
}
func (c *Handler) OnReload(reloadFunc ReloadFunc) {
c.reloadFunc = reloadFunc
}
func (c *Handler) Reload(ef EventFunc) error {
if ef == nil {
ef = func(string) {}
}
conf, err := c.Get()
if err != nil {
return err
}
if c.reloadFunc != nil {
return c.reloadFunc(conf, ef)
}
return nil
}
func (c *Handler) Set(b []byte) error {
if err := yaml.Unmarshal(b, &Root{}); err != nil {
return fmt.Errorf("error parsing configuration file: %w", err)