diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-09-12 17:24:34 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-09-12 17:37:41 +0200 |
commit | fcfa6f33bbebc128a3f9bc3162173bc3780c5f50 (patch) | |
tree | 8bb822e0f20fe8baa7eb60f370e4acffeb911419 /cache | |
parent | 77b23fe3db9ff86216887c317249a9a7e990139f (diff) | |
download | hugo-fcfa6f33bbebc128a3f9bc3162173bc3780c5f50.tar.gz hugo-fcfa6f33bbebc128a3f9bc3162173bc3780c5f50.zip |
filecache: Ignore "does not exist" errors in prune
Fixes #6326
Fixes #5745
Diffstat (limited to 'cache')
-rw-r--r-- | cache/filecache/filecache_pruner.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/cache/filecache/filecache_pruner.go b/cache/filecache/filecache_pruner.go index c6fd4497e..7f68c8b82 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 |