Skip to content

Commit

Permalink
修复cookie刷新配置读取错误
Browse files Browse the repository at this point in the history
  • Loading branch information
libsgh committed Jan 22, 2021
1 parent d0c894c commit 8edefba
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions jobs/Jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,41 @@ import (
"github.com/eddieivan01/nic"
"github.com/robfig/cron"
"log"
"os"
)

func Run() {
c := cron.New()
c.AddFunc("0 0/5 * * * ?", func() {
if config.Config189.HerokuAppUrl != "" {
resp, err := nic.Get(config.Config189.HerokuAppUrl, nil)
c.AddFunc(config.GloablConfig.CronExps.HerokuKeepAlive, func() {
if config.GloablConfig.HerokuAppUrl != "" && config.GloablConfig.CronExps.HerokuKeepAlive != "" {
resp, err := nic.Get(config.GloablConfig.HerokuAppUrl, nil)
if err != nil {
log.Println(err.Error())
} else {
log.Println("[定时任务]heroku防休眠 >> " + resp.Status)
}
}
})
c.AddFunc("0 0 8 1/1 * ?", func() {
Util.Cloud189Login(os.Getenv("USER"), os.Getenv("PASSWORD"))
c.AddFunc(config.GloablConfig.CronExps.RefreshCookie, func() {
Util.Cloud189Login(config.GloablConfig.User, config.GloablConfig.Password)
log.Println("[定时任务]cookie更新 >> 登录成功")
})
c.AddFunc("0 0 0/1 * * ?", func() {
c.AddFunc(config.GloablConfig.CronExps.UpdateFolderCache, func() {
model.SqliteDb.Model(&entity.FileNode{}).Update("`delete`", "1")
Util.Cloud189GetFiles(config.Config189.RootId, config.Config189.RootId)
Util.Cloud189GetFiles(config.GloablConfig.RootId, config.GloablConfig.RootId)
model.SqliteDb.Delete(entity.FileNode{}, "`delete` = 1")
log.Println("[定时任务]目录缓存刷新 >> 刷新成功")
})
c.Start()
}
func StartInit() {
cookie := Util.Cloud189Login(config.Config189.User, config.Config189.Password)
cookie := Util.Cloud189Login(config.GloablConfig.User, config.GloablConfig.Password)
if cookie != "" {
log.Println("[程序启动]cookie更新 >> 登录成功")
} else {
log.Println("[程序启动]cookie更新 >> 登录失败,请检查用户名和密码是否正确")
}
model.SqliteDb.Model(&entity.FileNode{}).Update("`delete`", "1")
Util.Cloud189GetFiles(config.Config189.RootId, config.Config189.RootId)
Util.Cloud189GetFiles(config.GloablConfig.RootId, config.GloablConfig.RootId)
model.SqliteDb.Delete(entity.FileNode{}, "`delete` = 1")
log.Println("[程序启动]目录缓存刷新 >> 刷新成功")
}

0 comments on commit 8edefba

Please sign in to comment.