Skip to content

Commit

Permalink
Merge pull request #16 from hibare/dev
Browse files Browse the repository at this point in the history
Fix: version check + nil pointer exeption
  • Loading branch information
hibare authored Apr 2, 2023
2 parents c06d500 + c153ef4 commit 83db576
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions internal/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ func Upload(sess *session.Session, bucket, prefix, baseDir string) (int, int, in
totalDirs = len(dirs)

for _, file := range files {
file, err := os.Open(file)
fp, err := os.Open(file)
if err != nil {
log.Errorf("Error opening file %s: %v", file.Name(), err)
log.Errorf("Error opening file %s: %v", file, err)
continue
}
defer file.Close()
defer fp.Close()

key := filepath.Join(prefix, strings.TrimPrefix(file.Name(), baseDirParentPath))
key := filepath.Join(prefix, strings.TrimPrefix(file, baseDirParentPath))
_, err = client.PutObject(&s3.PutObjectInput{
Bucket: aws.String(bucket),
Key: aws.String(key),
Body: file,
Body: fp,
})
if err != nil {
log.Errorf("Error uploading file %s: %v", file.Name(), err)
log.Errorf("Error uploading file %s: %v", file, err)
continue
}
successFiles += 1
log.Infof("Uploaded %s to S3://%s/%s", file.Name(), bucket, key)
log.Infof("Uploaded %s to S3://%s/%s", file, bucket, key)
}

return totalFiles, totalDirs, successFiles
Expand Down
3 changes: 2 additions & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"

"github.com/hibare/GoS3Backup/internal/constants"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -47,7 +48,7 @@ func CheckLatestRelease() {
return
}

LatestVersion = release.TagName
LatestVersion = strings.TrimPrefix(release.TagName, "v")

status, _ := IsNewVersionAvailable()
log.Infof("Version update available: %v, Current version: %s, Latest Version: %s", status, CurrentVersion, LatestVersion)
Expand Down

0 comments on commit 83db576

Please sign in to comment.