Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Fix timezone issue on Windows (hopefully)
Browse files Browse the repository at this point in the history
Also use httpClient everywhere instead of default client
Adjust packaging script
  • Loading branch information
wilriker committed Jun 2, 2019
1 parent c48ff7b commit fd52d83
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
duetbackup
duetbackup-*
duetbackup.exe
*.tgz
19 changes: 14 additions & 5 deletions compile.fish
@@ -1,7 +1,16 @@
#!/usr/bin/env fish

env GOOS=linux GOARCH=arm go build -o duetbackup-linux-arm duetbackup.go
env GOOS=linux GOARCH=arm GOARM=7 go build -o duetbackup-linux-armv7 duetbackup.go
env GOOS=linux go build -o duetbackup-linux_amd64 duetbackup.go
env GOOS=windows go build -o duetbackup-windows_amd64 duetbackup.go
env GOOS=darwin go build -o duetbackup-darwin_amd64 duetbackup.go
env GOOS=linux GOARCH=arm go build duetbackup.go
and tar czf duetbackup-linux_arm.tgz duetbackup LICENSE

env GOOS=linux GOARCH=arm64 go build duetbackup.go
and tar czf duetbackup-linux_arm64.tgz duetbackup LICENSE

env GOOS=linux go build duetbackup.go
and tar czf duetbackup-linux_amd64.tgz duetbackup LICENSE

env GOOS=windows go build -o duetbackup.exe duetbackup.go
and zip -r duetbackup-windows_amd64.zip duetbackup.exe LICENSE

env GOOS=darwin go build duetbackup.go
and tar czf duetbackup-darwin_amd64.tgz duetbackup LICENSE
10 changes: 4 additions & 6 deletions duetbackup.go
Expand Up @@ -57,10 +57,8 @@ func (f *file) UnmarshalJSON(b []byte) (err error) {
// FIXME This needs to be solved better!
// Get timezone offset to append to the date string that has no timezone offset
once.Do(func() {
loc, _ := time.LoadLocation("Europe/Berlin")
_, offset := time.Now().In(loc).Zone()
o := int64(offset) / 3600
offsetString = fmt.Sprintf("%+03d:00", o)
_, offset := time.Now().Zone()
offsetString = fmt.Sprintf("%+03d:00", int64(offset) / 3600)
})

// Parse date string
Expand All @@ -78,7 +76,7 @@ func getFileList(baseURL string, dir string, first uint64) (*filelist, error) {

fileListURL := "rr_filelist?dir="

resp, err := http.Get(baseURL + fileListURL + dir)
resp, err := httpClient.Get(baseURL + fileListURL + dir)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -241,7 +239,7 @@ func getAddress(domain string, port uint64) string {

func connect(address, password string) error {
path := "rr_connect?password=" + url.QueryEscape(password) + "&time=" + url.QueryEscape(time.Now().Format("2006-01-02T15:04:05"))
_, err := http.Get(address + path)
_, err := httpClient.Get(address + path)
return err
}

Expand Down

0 comments on commit fd52d83

Please sign in to comment.