mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 04:45:15 +00:00
small cleanup:
- be explicit when discarding returned errors from .Close(), etc. - remove named return values from funcs when naked return not used - fix some "err" shadowing when redeclaration not needed
This commit is contained in:
parent
8d37b723ca
commit
bcdebfb84e
@ -218,7 +218,7 @@ func (be *b2Backend) Load(ctx context.Context, h restic.Handle, length int, offs
|
||||
}
|
||||
|
||||
// Save stores data in the backend at the handle.
|
||||
func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (err error) {
|
||||
func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
@ -233,7 +233,7 @@ func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (e
|
||||
debug.Log("Save %v, name %v", h, name)
|
||||
obj := be.bucket.Object(name)
|
||||
|
||||
_, err = obj.Attrs(ctx)
|
||||
_, err := obj.Attrs(ctx)
|
||||
if err == nil {
|
||||
debug.Log(" %v already exists", h)
|
||||
return errors.New("key already exists")
|
||||
|
@ -118,7 +118,7 @@ func (b *Local) IsNotExist(err error) bool {
|
||||
}
|
||||
|
||||
// Save stores data in the backend at the handle.
|
||||
func (b *Local) Save(ctx context.Context, h restic.Handle, rd io.Reader) (err error) {
|
||||
func (b *Local) Save(ctx context.Context, h restic.Handle, rd io.Reader) (error) {
|
||||
debug.Log("Save %v", h)
|
||||
if err := h.Valid(); err != nil {
|
||||
return err
|
||||
|
2
internal/cache/cache.go
vendored
2
internal/cache/cache.go
vendored
@ -70,7 +70,7 @@ func writeCachedirTag(dir string) error {
|
||||
|
||||
debug.Log("Create CACHEDIR.TAG at %v", dir)
|
||||
if _, err := f.Write([]byte(cachedirTagSignature)); err != nil {
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
return errors.Wrap(err, "Write")
|
||||
}
|
||||
|
||||
|
2
internal/cache/file.go
vendored
2
internal/cache/file.go
vendored
@ -65,7 +65,7 @@ func (c *Cache) Load(h restic.Handle, length int, offset int64) (io.ReadCloser,
|
||||
|
||||
if offset > 0 {
|
||||
if _, err = f.Seek(offset, io.SeekStart); err != nil {
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
@ -674,8 +674,8 @@ func checkPack(ctx context.Context, r restic.Repository, id restic.ID) error {
|
||||
}
|
||||
|
||||
defer func() {
|
||||
packfile.Close()
|
||||
os.Remove(packfile.Name())
|
||||
_ = packfile.Close()
|
||||
_ = os.Remove(packfile.Name())
|
||||
}()
|
||||
|
||||
hrd := hashing.NewReader(rd, sha256.New())
|
||||
|
@ -67,7 +67,7 @@ func readDirNames(dirname string) ([]string, error) {
|
||||
return nil, errors.Wrap(err, "Open")
|
||||
}
|
||||
names, err := f.Readdirnames(-1)
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Readdirnames")
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func newLock(ctx context.Context, repo Repository, excl bool) (*Lock, error) {
|
||||
time.Sleep(waitBeforeLockCheck)
|
||||
|
||||
if err = lock.checkForOtherLocks(ctx); err != nil {
|
||||
lock.Unlock()
|
||||
_ = lock.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func (res *Restorer) restoreTo(ctx context.Context, dst string, dir string, tree
|
||||
debug.Log("SelectFilter returned %v %v", selectedForRestore, childMayBeSelected)
|
||||
|
||||
if selectedForRestore {
|
||||
err := res.restoreNodeTo(ctx, node, dir, dst, idx)
|
||||
err = res.restoreNodeTo(ctx, node, dir, dst, idx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -74,7 +74,8 @@ func (res *Restorer) restoreTo(ctx context.Context, dst string, dir string, tree
|
||||
if selectedForRestore {
|
||||
// Restore directory timestamp at the end. If we would do it earlier, restoring files within
|
||||
// the directory would overwrite the timestamp of the directory they are in.
|
||||
if err := node.RestoreTimestamps(filepath.Join(dst, dir, node.Name)); err != nil {
|
||||
err = node.RestoreTimestamps(filepath.Join(dst, dir, node.Name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user