From: Bjørn Erik Pedersen Date: Thu, 12 Sep 2019 15:24:34 +0000 (+0200) Subject: filecache: Ignore "does not exist" errors in prune X-Git-Tag: v0.58.2~4 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=fcfa6f33bbebc128a3f9bc3162173bc3780c5f50;p=brevno-suite%2Fhugo filecache: Ignore "does not exist" errors in prune Fixes #6326 Fixes #5745 --- diff --git a/cache/filecache/filecache_pruner.go b/cache/filecache/filecache_pruner.go index c6fd4497..7f68c8b8 100644 --- a/cache/filecache/filecache_pruner.go +++ b/cache/filecache/filecache_pruner.go @@ -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