mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
filecache: Ignore "does not exist" errors in prune
Fixes #6326 Fixes #5745
This commit is contained in:
19
cache/filecache/filecache_pruner.go
vendored
19
cache/filecache/filecache_pruner.go
vendored
@@ -31,12 +31,15 @@ func (c Caches) Prune() (int, error) {
|
|||||||
|
|
||||||
count, err := cache.Prune(false)
|
count, err := cache.Prune(false)
|
||||||
|
|
||||||
|
counter += count
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
return counter, errors.Wrapf(err, "failed to prune cache %q", k)
|
return counter, errors.Wrapf(err, "failed to prune cache %q", k)
|
||||||
}
|
}
|
||||||
|
|
||||||
counter += count
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return counter, nil
|
return counter, nil
|
||||||
@@ -68,7 +71,11 @@ func (c *Cache) Prune(force bool) (int, error) {
|
|||||||
_, err = f.Readdirnames(1)
|
_, err = f.Readdirnames(1)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
// Empty dir.
|
// Empty dir.
|
||||||
return c.Fs.Remove(name)
|
err = c.Fs.Remove(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -87,7 +94,11 @@ func (c *Cache) Prune(force bool) (int, error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
counter++
|
counter++
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user