cache: fix warning (#1162)
Fix warning about not existing cache file. Fixes: #925
This commit is contained in:
parent
90a8cd41bd
commit
fd0524f535
25
internal/cache/cache.go
vendored
25
internal/cache/cache.go
vendored
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user