From 537ab392362f83ed892e45c67b074ade448503db Mon Sep 17 00:00:00 2001 From: Julio Lopez <1953782+julio-lopez@users.noreply.github.com> Date: Thu, 6 Jul 2023 10:59:58 -0700 Subject: [PATCH] chore(general): cleanup "stale" error naming (#3129) 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. --- repo/blob/filesystem/filesystem_storage.go | 2 +- repo/blob/filesystem/osinterface.go | 4 +--- repo/blob/filesystem/osinterface_realos_other.go | 2 +- repo/blob/filesystem/osinterface_realos_unix.go | 6 ++---- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/repo/blob/filesystem/filesystem_storage.go b/repo/blob/filesystem/filesystem_storage.go index 1a9f5e207d1..d8895ce5256 100644 --- a/repo/blob/filesystem/filesystem_storage.go +++ b/repo/blob/filesystem/filesystem_storage.go @@ -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 diff --git a/repo/blob/filesystem/osinterface.go b/repo/blob/filesystem/osinterface.go index 06179a1dac7..c0fb2568203 100644 --- a/repo/blob/filesystem/osinterface.go +++ b/repo/blob/filesystem/osinterface.go @@ -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) @@ -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 { diff --git a/repo/blob/filesystem/osinterface_realos_other.go b/repo/blob/filesystem/osinterface_realos_other.go index f31e28074da..8e9be018eab 100644 --- a/repo/blob/filesystem/osinterface_realos_other.go +++ b/repo/blob/filesystem/osinterface_realos_other.go @@ -4,6 +4,6 @@ package filesystem //nolint:revive -func (realOS) IsESTALE(err error) bool { +func (realOS) IsStale(err error) bool { return false } diff --git a/repo/blob/filesystem/osinterface_realos_unix.go b/repo/blob/filesystem/osinterface_realos_unix.go index 15c71f0ec47..b18afbb9c57 100644 --- a/repo/blob/filesystem/osinterface_realos_unix.go +++ b/repo/blob/filesystem/osinterface_realos_unix.go @@ -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) }