From b110053fd590d5574e88f382036611bda54f74e4 Mon Sep 17 00:00:00 2001 From: Zhenzhen Zhao Date: Tue, 16 Apr 2019 20:52:50 +0800 Subject: [PATCH 1/5] Remove space character in "down_count" key --- item/info.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/item/info.go b/item/info.go index d91ff25..b7f2ad4 100644 --- a/item/info.go +++ b/item/info.go @@ -29,9 +29,9 @@ func GetItemInfo(c *gin.Context) { return } c.JSON(http.StatusOK, gin.H{ - "down_count ": item.DownCount, - "expired_at": item.ExpiredAt, - "is_public": item.IsPublic, + "down_count": item.DownCount, + "expired_at": item.ExpiredAt, + "is_public": item.IsPublic, }) return } From df57ee1893c0dedb91734f376245eb7408f4c116 Mon Sep 17 00:00:00 2001 From: Zhenzhen Zhao Date: Tue, 16 Apr 2019 21:02:12 +0800 Subject: [PATCH 2/5] Refact docker build file --- build/package/safeu-backend-dev/Dockerfile-compose | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/package/safeu-backend-dev/Dockerfile-compose b/build/package/safeu-backend-dev/Dockerfile-compose index f21544e..2246536 100644 --- a/build/package/safeu-backend-dev/Dockerfile-compose +++ b/build/package/safeu-backend-dev/Dockerfile-compose @@ -2,9 +2,6 @@ FROM golang:1.9.7 MAINTAINER TripleZ "me@triplez.cn" -WORKDIR $GOPATH/src/a2os/safeu-backend -ADD . $GOPATH/src/a2os/safeu-backend/ - # COPY conf/db.example.json $GOPATH/src/a2os/safeu-backend/conf/db.json # Solution for Chinese special network enviornment @@ -16,6 +13,9 @@ RUN mkdir -p $GOPATH/src/golang.org/x/ && \ # Add dependencies RUN go get github.com/pilu/fresh +WORKDIR $GOPATH/src/a2os/safeu-backend +ADD . $GOPATH/src/a2os/safeu-backend/ + # Build package RUN go build -o safeu-backend-dev . From 55843bc7c63ab0a21082f12c656a9f9ef20cfaff Mon Sep 17 00:00:00 2001 From: Zhenzhen Zhao Date: Tue, 16 Apr 2019 22:00:08 +0800 Subject: [PATCH 3/5] Fix download count cannot be zero --- item/downloadCount.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/item/downloadCount.go b/item/downloadCount.go index 1e61086..72356b0 100644 --- a/item/downloadCount.go +++ b/item/downloadCount.go @@ -77,7 +77,7 @@ func MinusDownloadCount(c *gin.Context) { // 下载次数-- singleItem.DownCount -= 1 - if singleItem.DownCount <= 0 { + if singleItem.DownCount < 0 { // 删除文件 err := DeleteItem(singleItem.Bucket, singleItem.Path) if err != nil { From e24c15618f481c00acf9f6dfdeaaf463a0c4ec9c Mon Sep 17 00:00:00 2001 From: Zhenzhen Zhao Date: Tue, 16 Apr 2019 22:17:55 +0800 Subject: [PATCH 4/5] Fix HTTPS signed download link --- item/download.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/item/download.go b/item/download.go index a9db20f..8de7f51 100644 --- a/item/download.go +++ b/item/download.go @@ -384,6 +384,9 @@ func GetSignURL(itemBucket string, itemPath string, client *oss.Client) (string, log.Println(fmt.Sprintf("Func: GetSignURL Get Bucket %s Object %s Failed %s", itemBucket, itemPath, err.Error())) return "", err } - log.Println("signed url: ", signedURL) - return signedURL, nil + + // TODO: 优雅一点……这个太暴力了 + signedHttpsURL := "https" + signedURL[4:] + log.Println("signed url: ", signedHttpsURL) + return signedHttpsURL, nil } From e6043409133d7987fd82f587c031a5dad531a59a Mon Sep 17 00:00:00 2001 From: Zhenzhen Zhao Date: Wed, 17 Apr 2019 16:14:22 +0800 Subject: [PATCH 5/5] Fix production overlapping log files - DEBUG = false --- common/const.go | 2 +- deployments/prod-safeu/docker-compose.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/const.go b/common/const.go index 6c6d5c2..9558e0a 100644 --- a/common/const.go +++ b/common/const.go @@ -3,7 +3,7 @@ package common var CloudConfig *CloudConfiguration const ( - DEBUG = true + DEBUG = false MAINTENANCE = false PORT = "8080" ) diff --git a/deployments/prod-safeu/docker-compose.yml b/deployments/prod-safeu/docker-compose.yml index 4f4a70c..182727b 100644 --- a/deployments/prod-safeu/docker-compose.yml +++ b/deployments/prod-safeu/docker-compose.yml @@ -22,7 +22,7 @@ services: context: ../.. dockerfile: ././build/package/safeu-backend/Dockerfile-compose volumes: - - ../../log/web1:/go/src/a2os/safeu-backend/log/ + - ../../log/safeu1:/go/src/a2os/safeu-backend/log # - ../..:/go/src/a2os/safeu-backend/ environment: - TZ=Asia/Shanghai @@ -39,7 +39,7 @@ services: context: ../.. dockerfile: ././build/package/safeu-backend/Dockerfile-compose volumes: - - ../../log/web2:/go/src/a2os/safeu-backend/log/ + - ../../log/safeu2:/go/src/a2os/safeu-backend/log # - ../..:/go/src/a2os/safeu-backend/ environment: - TZ=Asia/Shanghai @@ -56,7 +56,7 @@ services: context: ../.. dockerfile: ././build/package/safeu-backend/Dockerfile-compose volumes: - - ../../log/web2:/go/src/a2os/safeu-backend/log/ + - ../../log/safeu3:/go/src/a2os/safeu-backend/log # - ../..:/go/src/a2os/safeu-backend/ environment: - TZ=Asia/Shanghai