Added interval flag
This commit is contained in:
@@ -26,7 +26,7 @@ func (s *Server) HandleLoginPost(w http.ResponseWriter, r *http.Request) {
|
||||
Value: secret,
|
||||
Path: "/",
|
||||
MaxAge: 3600,
|
||||
Secure: true,
|
||||
Secure: false,
|
||||
HttpOnly: false,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
})
|
||||
|
||||
@@ -67,7 +67,6 @@ func (s *Server) RegisterRoutes() {
|
||||
s.mux.HandleFunc("/favicon.ico", s.HandleFavicon)
|
||||
s.mux.HandleFunc("POST /setting/", s.HandleSetting)
|
||||
s.mux.HandleFunc("GET /setting/set/{setting}/{value}", s.HandleSettingSet)
|
||||
|
||||
}
|
||||
|
||||
func (s *Server) StartTLS(port int, certFile, keyFile string) error {
|
||||
@@ -90,23 +89,25 @@ func (s *Server) Start(port int) error {
|
||||
return server.ListenAndServe()
|
||||
}
|
||||
|
||||
func (s *Server) RegisterUpdateMangas(interval time.Duration) {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(interval):
|
||||
var all []*database.Manga
|
||||
s.DbMgr.Db.Find(&all)
|
||||
for _, m := range all {
|
||||
err, updated := s.UpdateLatestAvailableChapter(m)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if updated {
|
||||
s.DbMgr.Db.Save(m)
|
||||
func (s *Server) RegisterUpdater(interval time.Duration) {
|
||||
go func(s *Server) {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(interval):
|
||||
var all []*database.Manga
|
||||
s.DbMgr.Db.Find(&all)
|
||||
for _, m := range all {
|
||||
err, updated := s.UpdateLatestAvailableChapter(m)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if updated {
|
||||
s.DbMgr.Db.Save(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}(s)
|
||||
}
|
||||
|
||||
func (s *Server) LoadNext() {
|
||||
|
||||
Reference in New Issue
Block a user