1
0
mirror of https://github.com/offen/docker-volume-backup.git synced 2025-11-23 21:44:40 +02:00

Update golangci integration (#637)

* Update golangci integration

* Fix newly discovered errcheck complaints

* Increase timeout value
This commit is contained in:
Frederik Ring
2025-09-09 20:50:46 +02:00
committed by GitHub
parent cbaa17d048
commit 746b8f71f9
13 changed files with 99 additions and 90 deletions

View File

@@ -11,14 +11,14 @@ import (
"strings"
"time"
"crypto/tls"
"github.com/offen/docker-volume-backup/internal/errwrap"
"github.com/offen/docker-volume-backup/internal/storage"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/drive/v3"
"google.golang.org/api/option"
"golang.org/x/oauth2"
"net/http"
"crypto/tls"
)
type googleDriveStorage struct {
@@ -84,15 +84,18 @@ func (b *googleDriveStorage) Name() string {
}
// Copy copies the given file to the Google Drive storage backend.
func (b *googleDriveStorage) Copy(file string) error {
func (b *googleDriveStorage) Copy(file string) (returnErr error) {
_, name := filepath.Split(file)
b.Log(storage.LogLevelInfo, b.Name(), "Starting upload for backup '%s'.", name)
f, err := os.Open(file)
if err != nil {
return errwrap.Wrap(err, fmt.Sprintf("failed to open file %s", file))
returnErr = errwrap.Wrap(err, fmt.Sprintf("failed to open file %s", file))
return
}
defer f.Close()
defer func() {
returnErr = f.Close()
}()
driveFile := &drive.File{Name: name}
if b.DestinationPath != "" {
@@ -104,7 +107,8 @@ func (b *googleDriveStorage) Copy(file string) error {
createCall := b.client.Files.Create(driveFile).SupportsAllDrives(true).Fields("id")
created, err := createCall.Media(f).Do()
if err != nil {
return errwrap.Wrap(err, fmt.Sprintf("failed to upload %s", name))
returnErr = errwrap.Wrap(err, fmt.Sprintf("failed to upload %s", name))
return
}
b.Log(storage.LogLevelInfo, b.Name(), "Finished upload for %s. File ID: %s", name, created.Id)