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

Commit e98a698

Browse files
committed
fix: Error: client/upload.go:58:16: constant 1200000000000 overflows int
1 parent 53a919e commit e98a698

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Backup Maker
22
============
33

4+
[![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)
5+
46
Tiny backup client packed in a single binary. Interacts with a `Backup Repository` server to store files, uses GPG to secure your
57
backups even against the server administrator.
68

client/http.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import (
77

88
type HTTPClient interface {
99
Do(req *http.Request) (*http.Response, error)
10-
SetTimeout(timeout int)
10+
SetTimeout(timeout int64)
1111
}
1212

1313
type HTTPClientImpl struct {
1414
client http.Client
15-
Timeout int
15+
Timeout int64
1616
}
1717

18-
func (that HTTPClientImpl) SetTimeout(timeout int) {
18+
func (that HTTPClientImpl) SetTimeout(timeout int64) {
1919
that.client.Timeout = time.Second * time.Duration(timeout)
2020
}
2121

client/upload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ func gracefullyKillProcess(cmd *exec.Cmd) error {
5353
}
5454

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

6161
url := fmt.Sprintf("%v/api/stable/repository/collection/%v/backup", domainWithSchema, collectionId)

context/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type ActionContext struct {
77
CollectionId string
88
AuthToken string
99
Command string
10-
Timeout int
10+
Timeout int64
1111
ActionType string
1212

1313
VersionToRestore string

main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ func createContextFromArgumentParsing() context.ActionContext {
6565
passphrase := ""
6666
recipient := ""
6767

68+
timeoutParam := *timeout
69+
6870
// prepare context
6971
ctx.Gpg.PublicKeyPath = *publicKeyPath // Public & Private keys are assigned there, but later will be re-assigned by factory method
7072
ctx.Url = *url
7173
ctx.CollectionId = *collectionId
7274
ctx.AuthToken = *authToken
73-
ctx.Timeout = *timeout
75+
ctx.Timeout = int64(timeoutParam)
7476
ctx.LogLevel = uint32(logLevel)
7577
if downloadCmd.Happened() {
7678
ctx.ActionType = "download"
@@ -131,7 +133,8 @@ func overrideFromEnvironment(ctx context.ActionContext, passphrase string, recip
131133
ctx.CollectionId = os.Getenv("BM_COLLECTION_ID")
132134
}
133135
if hasUsedEnvVariable("BM_TIMEOUT") {
134-
ctx.Timeout, _ = strconv.Atoi(os.Getenv("BM_TIMEOUT"))
136+
timeout, _ := strconv.Atoi(os.Getenv("BM_TIMEOUT"))
137+
ctx.Timeout = int64(timeout)
135138
}
136139
if hasUsedEnvVariable("BM_RECIPIENT") {
137140
recipient = os.Getenv("BM_RECIPIENT")

0 commit comments

Comments
 (0)