Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
fix: `Error: client/upload.go:58:16: constant 1200000000000 overflows…
Browse files Browse the repository at this point in the history
… int`
  • Loading branch information
blackandred committed Jan 18, 2022
1 parent 53a919e commit e98a698
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Backup Maker
============

[![Test](https://github.com/riotkit-org/br-backup-maker/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/riotkit-org/br-backup-maker/actions/workflows/test.yaml)

Tiny backup client packed in a single binary. Interacts with a `Backup Repository` server to store files, uses GPG to secure your
backups even against the server administrator.

Expand Down
6 changes: 3 additions & 3 deletions client/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import (

type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
SetTimeout(timeout int)
SetTimeout(timeout int64)
}

type HTTPClientImpl struct {
client http.Client
Timeout int
Timeout int64
}

func (that HTTPClientImpl) SetTimeout(timeout int) {
func (that HTTPClientImpl) SetTimeout(timeout int64) {
that.client.Timeout = time.Second * time.Duration(timeout)
}

Expand Down
4 changes: 2 additions & 2 deletions client/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func gracefullyKillProcess(cmd *exec.Cmd) error {
}

// Upload is uploading bytes read from io.Reader stream into HTTP endpoint of Backup Repository server
func Upload(domainWithSchema string, collectionId string, authToken string, body io.Reader, timeout int) (string, string, error) {
func Upload(domainWithSchema string, collectionId string, authToken string, body io.Reader, timeout int64) (string, string, error) {
if timeout == 0 {
timeout = int(time.Second * 60 * 20)
timeout = int64(time.Second * 60 * 20)
}

url := fmt.Sprintf("%v/api/stable/repository/collection/%v/backup", domainWithSchema, collectionId)
Expand Down
2 changes: 1 addition & 1 deletion context/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ActionContext struct {
CollectionId string
AuthToken string
Command string
Timeout int
Timeout int64
ActionType string

VersionToRestore string
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ func createContextFromArgumentParsing() context.ActionContext {
passphrase := ""
recipient := ""

timeoutParam := *timeout

// prepare context
ctx.Gpg.PublicKeyPath = *publicKeyPath // Public & Private keys are assigned there, but later will be re-assigned by factory method
ctx.Url = *url
ctx.CollectionId = *collectionId
ctx.AuthToken = *authToken
ctx.Timeout = *timeout
ctx.Timeout = int64(timeoutParam)
ctx.LogLevel = uint32(logLevel)
if downloadCmd.Happened() {
ctx.ActionType = "download"
Expand Down Expand Up @@ -131,7 +133,8 @@ func overrideFromEnvironment(ctx context.ActionContext, passphrase string, recip
ctx.CollectionId = os.Getenv("BM_COLLECTION_ID")
}
if hasUsedEnvVariable("BM_TIMEOUT") {
ctx.Timeout, _ = strconv.Atoi(os.Getenv("BM_TIMEOUT"))
timeout, _ := strconv.Atoi(os.Getenv("BM_TIMEOUT"))
ctx.Timeout = int64(timeout)
}
if hasUsedEnvVariable("BM_RECIPIENT") {
recipient = os.Getenv("BM_RECIPIENT")
Expand Down

0 comments on commit e98a698

Please sign in to comment.