chore: add log

This commit is contained in:
Simon Ding
2024-07-12 16:48:41 +08:00
parent 3da71c1f9f
commit 9dae98eae5
2 changed files with 3 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ func (s *Server) checkTasks() {
log.Infof("begin check tasks...")
for id, t := range s.tasks {
if !t.Exists() {
log.Infof("task no longer exists: %v", t.Name())
continue
}
log.Infof("task (%s) percentage done: %d%%", t.Name(), t.Progress())

View File

@@ -33,7 +33,6 @@ type Server struct {
tasks map[int]pkg.Torrent
}
func (s *Server) Serve() error {
s.scheduler()
s.reloadTasks()
@@ -107,14 +106,13 @@ func (s *Server) MustTMDB() *tmdb.Client {
return t
}
func (s *Server) reloadTasks() {
runningTasks := s.db.GetRunningHistories()
if len(runningTasks) == 0 {
return
}
for _, t := range runningTasks {
log.Infof("reloading task: %s", t.SourceTitle)
log.Infof("reloading task: %d %s", t.ID, t.SourceTitle)
torrent, err := transmission.ReloadTorrent(t.Saved)
if err != nil {
log.Errorf("relaod task %s failed: %v", t.SourceTitle, err)
@@ -122,4 +120,4 @@ func (s *Server) reloadTasks() {
}
s.tasks[t.ID] = torrent
}
}
}