From fd0524f535c89eb4eab85a245ef74e0a3873a729 Mon Sep 17 00:00:00 2001 From: Denis Isaev Date: Sun, 24 May 2020 10:19:00 +0300 Subject: [PATCH] cache: fix warning (#1162) Fix warning about not existing cache file. Fixes: #925 --- internal/cache/cache.go | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/internal/cache/cache.go b/internal/cache/cache.go index ae5b7da18e0f..51c75a77d2da 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -81,7 +81,7 @@ func (c *Cache) fileName(id [HashSize]byte, key string) string { var errMissing = errors.New("cache entry not found") func IsErrMissing(err error) bool { - return err == errMissing + return errors.Cause(err) == errMissing } const ( @@ -199,26 +199,6 @@ func (c *Cache) get(id ActionID) (Entry, error) { return Entry{buf, size, time.Unix(0, tm)}, nil } -// GetFile looks up the action ID in the cache and returns -// the name of the corresponding data file. -func (c *Cache) GetFile(id ActionID) (file string, entry Entry, err error) { - entry, err = c.Get(id) - if err != nil { - return "", Entry{}, err - } - - file, err = c.OutputFile(entry.OutputID) - if err != nil { - return "", Entry{}, err - } - - info, err := os.Stat(file) - if err != nil || info.Size() != entry.Size { - return "", Entry{}, errMissing - } - return file, entry, nil -} - // GetBytes looks up the action ID in the cache and returns // the corresponding output bytes. // GetBytes should only be used for data that can be expected to fit in memory. @@ -282,6 +262,9 @@ const ( func (c *Cache) used(file string) error { info, err := os.Stat(file) if err != nil { + if os.IsNotExist(err) { + return errMissing + } return errors.Wrapf(err, "failed to stat file %s", file) }