Add and remove torrents from web interface (#84)
This commit is contained in:
parent
02842b1917
commit
2f18213660
49 changed files with 996 additions and 1170 deletions
config
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue