Skip to content

Commit fd0524f

Browse files
authored
cache: fix warning (#1162)
Fix warning about not existing cache file. Fixes: #925
1 parent 90a8cd4 commit fd0524f

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

internal/cache/cache.go

+4-21
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (c *Cache) fileName(id [HashSize]byte, key string) string {
8181
var errMissing = errors.New("cache entry not found")
8282

8383
func IsErrMissing(err error) bool {
84-
return err == errMissing
84+
return errors.Cause(err) == errMissing
8585
}
8686

8787
const (
@@ -199,26 +199,6 @@ func (c *Cache) get(id ActionID) (Entry, error) {
199199
return Entry{buf, size, time.Unix(0, tm)}, nil
200200
}
201201

202-
// GetFile looks up the action ID in the cache and returns
203-
// the name of the corresponding data file.
204-
func (c *Cache) GetFile(id ActionID) (file string, entry Entry, err error) {
205-
entry, err = c.Get(id)
206-
if err != nil {
207-
return "", Entry{}, err
208-
}
209-
210-
file, err = c.OutputFile(entry.OutputID)
211-
if err != nil {
212-
return "", Entry{}, err
213-
}
214-
215-
info, err := os.Stat(file)
216-
if err != nil || info.Size() != entry.Size {
217-
return "", Entry{}, errMissing
218-
}
219-
return file, entry, nil
220-
}
221-
222202
// GetBytes looks up the action ID in the cache and returns
223203
// the corresponding output bytes.
224204
// GetBytes should only be used for data that can be expected to fit in memory.
@@ -282,6 +262,9 @@ const (
282262
func (c *Cache) used(file string) error {
283263
info, err := os.Stat(file)
284264
if err != nil {
265+
if os.IsNotExist(err) {
266+
return errMissing
267+
}
285268
return errors.Wrapf(err, "failed to stat file %s", file)
286269
}
287270

0 commit comments

Comments
 (0)