Skip to content

Commit

Permalink
chore(general): cleanup "stale" error naming (kopia#3129)
Browse files Browse the repository at this point in the history
Rename IsESTALE to IsStale to make it consistent with
the conventions in the Go ecosystem

Use errors.Is() instead of == comparison. It is more robust.
  • Loading branch information
julio-lopez authored Jul 6, 2023
1 parent 439fbbf commit 537ab39
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion repo/blob/filesystem/filesystem_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (fs *fsImpl) isRetriable(err error) bool {

err = errors.Cause(err)

if fs.osi.IsESTALE(err) {
if fs.osi.IsStale(err) {
// errors indicative of stale resource handle or invalid
// descriptors should not be retried
return false
Expand Down
4 changes: 1 addition & 3 deletions repo/blob/filesystem/osinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type osInterface interface {
IsPathError(err error) bool
IsLinkError(err error) bool
IsPathSeparator(c byte) bool
IsStale(err error) bool
Remove(fname string) error
Rename(oldname, newname string) error
ReadDir(dirname string) ([]fs.DirEntry, error)
Expand All @@ -27,9 +28,6 @@ type osInterface interface {
Chtimes(fname string, atime, mtime time.Time) error
Geteuid() int
Chown(fname string, uid, gid int) error

// Errno
IsESTALE(err error) bool
}

type osReadFile interface {
Expand Down
2 changes: 1 addition & 1 deletion repo/blob/filesystem/osinterface_realos_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
package filesystem

//nolint:revive
func (realOS) IsESTALE(err error) bool {
func (realOS) IsStale(err error) bool {
return false
}
6 changes: 2 additions & 4 deletions repo/blob/filesystem/osinterface_realos_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/pkg/errors"
)

func (realOS) IsESTALE(err error) bool {
var errno syscall.Errno

return errors.As(err, &errno) && errno == syscall.ESTALE
func (realOS) IsStale(err error) bool {
return errors.Is(err, syscall.ESTALE)
}

0 comments on commit 537ab39

Please sign in to comment.