跳过检查更新

This commit is contained in:
微凉
2021-02-27 20:06:09 +08:00
parent 0e7083a713
commit 9cb548d4f7
5 changed files with 28 additions and 10 deletions

View File

@ -27,6 +27,7 @@ type DownloadReq struct {
DriveId string `json:"drive_id"` DriveId string `json:"drive_id"`
FileId string `json:"file_id"` FileId string `json:"file_id"`
ExpireSec int `json:"expire_sec"` ExpireSec int `json:"expire_sec"`
FileName string `json:"file_name"`
} }
// search request bean // search request bean

View File

@ -29,14 +29,14 @@ func GetFile(fileId string) (*File, error) {
} }
// get download_url // get download_url
func GetDownLoadUrl(fileId string) (*File, error) { func GetDownLoadUrl(fileId string) (*DownloadResp, error) {
url:=conf.Conf.AliDrive.ApiUrl+"/file/get_download_url" url:=conf.Conf.AliDrive.ApiUrl+"/file/get_download_url"
req:=DownloadReq{ req:=DownloadReq{
DriveId: User.DefaultDriveId, DriveId: User.DefaultDriveId,
FileId: fileId, FileId: fileId,
ExpireSec: 14400, ExpireSec: 14400,
} }
var resp File var resp DownloadResp
if err := BodyToJson(url, req, &resp, true); err!=nil { if err := BodyToJson(url, req, &resp, true); err!=nil {
return nil,err return nil,err
} }

View File

@ -10,9 +10,9 @@ import (
// response bean methods // response bean methods
type RespHandle interface { type RespHandle interface {
IsAvailable() bool // check available IsAvailable() bool // check available
GetCode() string // get err code GetCode() string // get err code
GetMessage() string // get err message GetMessage() string // get err message
SetCode(code string) // set err code SetCode(code string) // set err code
} }
@ -26,16 +26,16 @@ func (resp *RespError) IsAvailable() bool {
return resp.Code == "" return resp.Code == ""
} }
func (resp *RespError)GetCode() string { func (resp *RespError) GetCode() string {
return resp.Code return resp.Code
} }
func (resp *RespError)GetMessage() string { func (resp *RespError) GetMessage() string {
return resp.Message return resp.Message
} }
func (resp *RespError)SetCode(code string) { func (resp *RespError) SetCode(code string) {
resp.Code=code resp.Code = code
} }
// user_info response bean // user_info response bean
@ -104,6 +104,18 @@ type File struct {
Paths []Path `json:"paths"` Paths []Path `json:"paths"`
} }
type DownloadResp struct {
RespError
Expiration string `json:"expiration"`
Method string `json:"method"`
Size int64 `json:"size"`
Url string `json:"url"`
//RateLimit struct{
// PartSize int `json:"part_size"`
// PartSpeed int `json:"part_speed"`
//} `json:"rate_limit"`//rate limit
}
// token_login response bean // token_login response bean
type TokenLoginResp struct { type TokenLoginResp struct {
RespError RespError

View File

@ -14,6 +14,7 @@ func init() {
flag.BoolVar(&conf.Help,"help",false,"show usage help") flag.BoolVar(&conf.Help,"help",false,"show usage help")
flag.BoolVar(&conf.Version,"version",false,"show version info") flag.BoolVar(&conf.Version,"version",false,"show version info")
flag.StringVar(&conf.Con,"conf","conf.yml","config file") flag.StringVar(&conf.Con,"conf","conf.yml","config file")
flag.BoolVar(&conf.SkipUpdate,"skip-update",false,"skip update")
} }
// bootstrap run // bootstrap run
@ -48,7 +49,9 @@ func printASC() {
func start() { func start() {
InitLog() InitLog()
printASC() printASC()
CheckUpdate() if !conf.SkipUpdate {
CheckUpdate()
}
if !ReadConf(conf.Con) { if !ReadConf(conf.Con) {
log.Errorf("读取配置文件时出现错误,启动失败.") log.Errorf("读取配置文件时出现错误,启动失败.")
return return

View File

@ -10,6 +10,8 @@ var(
Help bool // is help command Help bool // is help command
Version bool // is print version command Version bool // is print version command
Con string // config file Con string // config file
SkipUpdate bool // skip update
Client *http.Client // request client Client *http.Client // request client
Authorization string // authorization string Authorization string // authorization string