Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
update rss content on runtime changed
Browse files Browse the repository at this point in the history
  • Loading branch information
boypt committed Jul 16, 2021
1 parent eb8d1c5 commit bc50088
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
NeedRestartWatch
NeedUpdateTracker
NeedLoadWaitList
NeedUpdateRSS
)

const (
Expand Down Expand Up @@ -124,7 +125,7 @@ func (c *Config) NormlizeConfigDir() (bool, error) {
if c.DownloadDirectory != "" {
dldir, err := filepath.Abs(c.DownloadDirectory)
if err != nil {
return false, fmt.Errorf("Invalid path %s, %w", c.WatchDirectory, err)
return false, fmt.Errorf("ERROR: Invalid path %s, %w", c.WatchDirectory, err)
}
if c.DownloadDirectory != dldir {
changed = true
Expand All @@ -135,7 +136,7 @@ func (c *Config) NormlizeConfigDir() (bool, error) {
if c.WatchDirectory != "" {
wdir, err := filepath.Abs(c.WatchDirectory)
if err != nil {
return false, fmt.Errorf("Invalid path %s, %w", c.WatchDirectory, err)
return false, fmt.Errorf("ERROR: Invalid path %s, %w", c.WatchDirectory, err)
}
if c.WatchDirectory != wdir {
changed = true
Expand Down Expand Up @@ -182,6 +183,9 @@ func (c *Config) Validate(nc *Config) uint8 {
if c.MaxConcurrentTask < nc.MaxConcurrentTask {
status |= NeedLoadWaitList
}
if c.RssURL != nc.RssURL {
status |= NeedUpdateRSS
}

rfc := reflect.ValueOf(c)
rfnc := reflect.ValueOf(nc)
Expand Down
3 changes: 3 additions & 0 deletions server/server_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func (s *Server) apiConfigure(data []byte) error {
if status&engine.NeedUpdateTracker > 0 {
go s.engine.ParseTrackerList()
}
if status&engine.NeedUpdateRSS > 0 {
go s.updateRSS()
}
s.state.Push()

// do after config synced
Expand Down

0 comments on commit bc50088

Please sign in to comment.