From 838d6de32d4888e71bdb38c2f42fda96d935649d Mon Sep 17 00:00:00 2001 From: Chris Roche Date: Mon, 4 Sep 2017 20:40:32 -0700 Subject: [PATCH] CacheOnReadFS: Use os.IsNotExist to correctly detect cache misses --- cacheOnReadFs.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cacheOnReadFs.go b/cacheOnReadFs.go index e54a4f8..b026e0d 100644 --- a/cacheOnReadFs.go +++ b/cacheOnReadFs.go @@ -64,15 +64,10 @@ func (u *CacheOnReadFs) cacheStatus(name string) (state cacheState, fi os.FileIn return cacheHit, lfi, nil } - if err == syscall.ENOENT { + if err == syscall.ENOENT || os.IsNotExist(err) { return cacheMiss, nil, nil } - var ok bool - if err, ok = err.(*os.PathError); ok { - if err == os.ErrNotExist { - return cacheMiss, nil, nil - } - } + return cacheMiss, nil, err }