fix: unwrapping issues with os.Is* functions (#10949)

reduces  3 stat calls, reducing the
overall startup time significantly.
This commit is contained in:
Harshavardhana
2020-11-23 08:36:49 -08:00
committed by GitHub
parent 39f3d5493b
commit df93102235
22 changed files with 158 additions and 166 deletions

View File

@@ -93,9 +93,9 @@ func (fsi *fsIOPool) Open(path string) (*lock.RLockedFile, error) {
newRlkFile, err := lock.RLockedOpenFile(path)
if err != nil {
switch {
case os.IsNotExist(err):
case osIsNotExist(err):
return nil, errFileNotFound
case os.IsPermission(err):
case osIsPermission(err):
return nil, errFileAccessDenied
case isSysErrIsDir(err):
return nil, errIsNotRegular
@@ -150,9 +150,9 @@ func (fsi *fsIOPool) Write(path string) (wlk *lock.LockedFile, err error) {
wlk, err = lock.LockedOpenFile(path, os.O_RDWR, 0666)
if err != nil {
switch {
case os.IsNotExist(err):
case osIsNotExist(err):
return nil, errFileNotFound
case os.IsPermission(err):
case osIsPermission(err):
return nil, errFileAccessDenied
case isSysErrIsDir(err):
return nil, errIsNotRegular
@@ -182,7 +182,7 @@ func (fsi *fsIOPool) Create(path string) (wlk *lock.LockedFile, err error) {
wlk, err = lock.LockedOpenFile(path, os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
switch {
case os.IsPermission(err):
case osIsPermission(err):
return nil, errFileAccessDenied
case isSysErrIsDir(err):
return nil, errIsNotRegular