From 4af469efed8524fae6dc33075382d46c0fca4028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <36558727+Xhofe@users.noreply.github.com> Date: Sat, 26 Dec 2020 18:11:17 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=97=B6=E9=97=B4=E8=B6=85=E5=87=BAint?= =?UTF-8?q?=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 71 +++++++++++++++++++++++++++++++++++++ README.md | 3 +- alidrive/request.go | 1 + alidrive/resp_bean.go | 8 ++--- bootstrap/alidrive.go | 1 + bootstrap/client.go | 2 ++ bootstrap/cmd.go | 4 +-- bootstrap/config.go | 1 + server/router.go | 2 ++ 9 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..a39e7e3a78d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,71 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + + build: + strategy: + matrix: + platform: [ubuntu-latest] + go-version: [1.15] + name: Build + runs-on: ${{ matrix.platform }} + steps: + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + sudo apt-get update + sudo apt-get -y install gcc-mingw-w64-x86-64 + sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross + sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + - name: Build linux + run: | + CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o alist_linux_amd64 alist.go + CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o alist_linux_arm64 alist.go + CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o alist_linux_arm alist.go + + - name: Build windows + run: | + CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o alist_windows_amd64.exe alist.go + + - name: Upload artifacts linux_amd64 + uses: actions/upload-artifact@v2 + with: + name: alist_linux_amd64 + path: alist_linux_amd64 + + - name: Upload artifacts linux_arm64 + uses: actions/upload-artifact@v2 + with: + name: alist_linux_arm64 + path: alist_linux_arm64 + + - name: Upload artifacts linux_arm + uses: actions/upload-artifact@v2 + with: + name: alist_linux_arm + path: alist_linux_arm + + - name: Upload artifacts windows_amd64 + uses: actions/upload-artifact@v2 + with: + name: alist_windows_amd64 + path: alist_windows_amd64.exe \ No newline at end of file diff --git a/README.md b/README.md index cf5944e6412..6f4c5534cb3 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,14 @@

Release version - Release status + Build status Downloads License donate

+ --- ### 这是什么? diff --git a/alidrive/request.go b/alidrive/request.go index 91f726d4756..10b96f4ac89 100644 --- a/alidrive/request.go +++ b/alidrive/request.go @@ -175,6 +175,7 @@ func DoPost(url string,request interface{},auth bool) (body []byte, err error) { if body, err = ioutil.ReadAll(resp.Body); err != nil { log.Errorf("读取api返回内容失败") } + log.Debugf("请求返回信息:%s",string(body)) return } diff --git a/alidrive/resp_bean.go b/alidrive/resp_bean.go index f69a2855308..ae26517c77a 100644 --- a/alidrive/resp_bean.go +++ b/alidrive/resp_bean.go @@ -18,8 +18,8 @@ type UserInfo struct { DomainId string `json:"domain_id"` UserId string `json:"user_id"` Avatar string `json:"avatar"` - CreatedAt int `json:"created_at"` - UpdatedAt int `json:"updated_at"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` Email string `json:"email"` NickName string `json:"nick_name"` Phone string `json:"phone"` @@ -66,8 +66,8 @@ type File struct { ContentType string `json:"content_type"` Crc64Hash string `json:"crc_64_hash"` DownloadUrl string `json:"download_url"` - PunishFlag int `json:"punish_flag"` - Size int `json:"size"` + PunishFlag int64 `json:"punish_flag"` + Size int64 `json:"size"` Thumbnail string `json:"thumbnail"` Url string `json:"url"` ImageMediaMetadata map[string]interface{} `json:"image_media_metadata"` diff --git a/bootstrap/alidrive.go b/bootstrap/alidrive.go index 36dd1eddd44..39f251bf8ca 100644 --- a/bootstrap/alidrive.go +++ b/bootstrap/alidrive.go @@ -7,6 +7,7 @@ import ( ) func InitAliDrive() bool { + log.Infof("初始化阿里云盘...") //首先token_login if conf.Conf.AliDrive.RefreshToken == "" { tokenLogin,err:=alidrive.TokenLogin() diff --git a/bootstrap/client.go b/bootstrap/client.go index 38895fe2c05..4cf536bb9d0 100644 --- a/bootstrap/client.go +++ b/bootstrap/client.go @@ -2,9 +2,11 @@ package bootstrap import ( "github.com/Xhofe/alist/conf" + log "github.com/sirupsen/logrus" "net/http" ) func InitClient() { + log.Infof("初始化client...") conf.Client=&http.Client{} } \ No newline at end of file diff --git a/bootstrap/cmd.go b/bootstrap/cmd.go index 06a38db8eaf..319895670a6 100644 --- a/bootstrap/cmd.go +++ b/bootstrap/cmd.go @@ -39,11 +39,11 @@ func printASC() { func start() { InitLog() printASC() - InitClient() if !ReadConf(conf.Con) { log.Errorf("读取配置文件时出现错误,启动失败.") return } + InitClient() if !InitAliDrive() { log.Errorf("初始化阿里云盘出现错误,启动失败.") return @@ -54,9 +54,9 @@ func start() { func server() { baseServer:="0.0.0.0:"+conf.Conf.Server.Port - log.Infof("Starting server @ %s",baseServer) r:=gin.Default() serv.InitRouter(r) + log.Infof("Starting server @ %s",baseServer) err:=r.Run(baseServer) if err!=nil { log.Errorf("Server failed start:%s",err.Error()) diff --git a/bootstrap/config.go b/bootstrap/config.go index a25d5c29ed7..30b9a37c8fd 100644 --- a/bootstrap/config.go +++ b/bootstrap/config.go @@ -9,6 +9,7 @@ import ( ) func ReadConf(config string) bool { + log.Infof("读取配置文件...") if !utils.Exists(config) { log.Infof("找不到配置文件:%s",config) return false diff --git a/server/router.go b/server/router.go index 950de8a261b..da0031ae578 100644 --- a/server/router.go +++ b/server/router.go @@ -4,9 +4,11 @@ import ( "github.com/Xhofe/alist/conf" "github.com/gin-contrib/static" "github.com/gin-gonic/gin" + log "github.com/sirupsen/logrus" ) func InitRouter(engine *gin.Engine) { + log.Infof("初始化路由...") engine.Use(CrosHandler()) InitApiRouter(engine) }