Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/backup/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package main

import (
"archive/tar"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -164,7 +165,7 @@ func writeTarball(path string, tarWriter *tar.Writer, prefix string) (returnErr
return
}
defer func() {
returnErr = file.Close()
returnErr = errors.Join(returnErr, file.Close())
}()

_, err = io.Copy(tarWriter, file)
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/dropbox/dropbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dropbox
import (
"bytes"
"context"
"errors"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -111,7 +112,7 @@ func (b *dropboxStorage) Copy(file string) (returnErr error) {
return
}
defer func() {
returnErr = r.Close()
returnErr = errors.Join(returnErr, r.Close())
}()

// Start new upload session and get session id
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/googledrive/googledrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package googledrive

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -97,7 +98,7 @@ func (b *googleDriveStorage) Copy(file string) (returnErr error) {
return
}
defer func() {
returnErr = f.Close()
returnErr = errors.Join(returnErr, f.Close())
}()

driveFile := &drive.File{Name: name}
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func copyFile(src, dst string) (returnErr error) {
return
}
defer func() {
returnErr = in.Close()
returnErr = errors.Join(returnErr, in.Close())
}()

out, err := os.Create(dst)
Expand Down
7 changes: 4 additions & 3 deletions internal/storage/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func (b *sshStorage) Name() string {
// Copy copies the given file to the SSH storage backend.
func (b *sshStorage) Copy(file string) (returnErr error) {
if err := b.sftpClient.MkdirAll(b.DestinationPath); err != nil {
return errwrap.Wrap(err, "error ensuring destination directory")
returnErr = errwrap.Wrap(err, "error ensuring destination directory")
return
}

source, err := os.Open(file)
Expand All @@ -120,7 +121,7 @@ func (b *sshStorage) Copy(file string) (returnErr error) {
return
}
defer func() {
returnErr = source.Close()
returnErr = errors.Join(returnErr, source.Close())
}()

destination, err := b.sftpClient.Create(path.Join(b.DestinationPath, name))
Expand All @@ -129,7 +130,7 @@ func (b *sshStorage) Copy(file string) (returnErr error) {
return
}
defer func() {
returnErr = destination.Close()
returnErr = errors.Join(returnErr, destination.Close())
}()

chunk := make([]byte, 1e9)
Expand Down
Loading