filecache: Ignore "does not exist" errors in prune

Fixes #6326
Fixes #5745
This commit is contained in:
Bjørn Erik Pedersen 2019-09-12 17:24:34 +02:00
parent 77b23fe3db
commit fcfa6f33bb
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -31,12 +31,15 @@ func (c Caches) Prune() (int, error) {
count, err := cache.Prune(false)
counter += count
if err != nil {
if os.IsNotExist(err) {
continue
}
return counter, errors.Wrapf(err, "failed to prune cache %q", k)
}
counter += count
}
return counter, nil
@ -68,7 +71,11 @@ func (c *Cache) Prune(force bool) (int, error) {
_, err = f.Readdirnames(1)
if err == io.EOF {
// Empty dir.
return c.Fs.Remove(name)
err = c.Fs.Remove(name)
}
if err != nil && !os.IsNotExist(err) {
return err
}
return nil
@ -87,7 +94,11 @@ func (c *Cache) Prune(force bool) (int, error) {
if err == nil {
counter++
}
return err
if err != nil && !os.IsNotExist(err) {
return err
}
}
return nil