🍃 去除文件缓存

This commit is contained in:
微凉
2020-12-31 15:03:25 +08:00
parent ba7c33a2bb
commit d5e3527bfb
12 changed files with 84 additions and 46 deletions

View File

@@ -24,13 +24,13 @@ func InitAliDrive() bool {
}else {
conf.Authorization=conf.Bearer+conf.Conf.AliDrive.AccessToken
}
log.Infof("token:%s",conf.Authorization)
log.Debugf("token:%s",conf.Authorization)
user,err:=alidrive.GetUserInfo()
if err != nil {
log.Errorf("初始化用户失败:%s",err.Error())
return false
}
log.Infof("当前用户信息:%v",user)
log.Infof("当前用户信息:%+v",user)
alidrive.User=user
return true
}

View File

@@ -39,6 +39,7 @@ func printASC() {
func start() {
InitLog()
printASC()
CheckUpdate()
if !ReadConf(conf.Con) {
log.Errorf("读取配置文件时出现错误,启动失败.")
return

View File

@@ -24,6 +24,6 @@ func ReadConf(config string) bool {
log.Errorf("加载配置文件时发生错误:%s",err.Error())
return false
}
log.Debugf("config:%v",conf.Conf)
log.Debugf("config:%+v",conf.Conf)
return true
}

41
bootstrap/update.go Normal file
View File

@@ -0,0 +1,41 @@
package bootstrap
import (
"encoding/json"
"github.com/Xhofe/alist/conf"
log "github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
)
type GithubRelease struct {
TagName string `json:"tag_name"`
HtmlUrl string `json:"html_url"`
Body string `json:"body"`
}
func CheckUpdate() {
url:="https://api.github.com/repos/Xhofe/alist/releases/latest"
resp,err:=http.Get(url)
if err!=nil {
log.Warnf("检查更新失败:%s",err.Error())
return
}
body,err:=ioutil.ReadAll(resp.Body)
if err!=nil {
log.Warnf("读取更新内容失败:%s",err.Error())
return
}
var release GithubRelease
err = json.Unmarshal(body,&release)
if err!=nil {
log.Warnf("解析更新失败:%s",err.Error())
return
}
if conf.VERSION == release.TagName {
log.Infof("当前已是最新版本:%s",release.TagName)
}else {
log.Infof("发现新版本:%s",release.TagName)
log.Infof("请至'%s'获取更新.",release.HtmlUrl)
}
}