Skip to content

Commit

Permalink
fix: RefreshedDate null cause auto refresh failed
Browse files Browse the repository at this point in the history
  • Loading branch information
bitxeno committed Jul 22, 2024
1 parent 75d2117 commit 76707c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions internal/service/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"strings"
"time"

"github.com/bitxeno/atvloadly/internal/log"
"github.com/bitxeno/atvloadly/internal/manager"
Expand Down Expand Up @@ -67,6 +68,8 @@ func runInstallMessage(mgr *manager.WebsocketManager, installMgr *manager.Instal
}

if strings.Contains(installMgr.OutputLog(), "Installation Succeeded") {
now := time.Now()
v.RefreshedDate = &now
v.RefreshedResult = true
app, err := SaveApp(v)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions internal/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ func (t *Task) runQueue() {
func (t *Task) checkNeedRefresh(v model.InstalledApp) bool {
now := time.Now()

// 过期时间少于一天时,再安装
// fix RefreshedDate is nil
if v.RefreshedDate == nil {
return true
}

// refresh when the expiration time is less than one day.
if app.Settings.Task.Mode == app.OneDayAgoMode {
expireTime := v.RefreshedDate.AddDate(0, 0, 6)
if expireTime.Before(now) {
Expand Down Expand Up @@ -171,7 +176,6 @@ func (t *Task) runInternal(v model.InstalledApp) error {
}
}


func ScheduleRefreshApps() error {
return instance.RunSchedule()
}
Expand Down

0 comments on commit 76707c6

Please sign in to comment.