diff options
author | Oleksandr Redko <[email protected]> | 2023-03-04 16:49:25 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-03-04 18:47:43 +0100 |
commit | 184a67ac4704b88083c43a68a5f85800192d7ff1 (patch) | |
tree | c2acdbbf5f1b3c2c8fc2d66f835fadaab0d3ae3f /cache/filecache | |
parent | 6c798eba607a7e019cc1dfce6fd68be7f770c5bd (diff) | |
download | hugo-184a67ac4704b88083c43a68a5f85800192d7ff1.tar.gz hugo-184a67ac4704b88083c43a68a5f85800192d7ff1.zip |
cache: Fix --gc failure on Windows
Fixes "Error: failed to prune cache" on Windows and removes
work around from ec1c97e7e9d62ce5245135e0906fdedf14af0cae.
Follows #10781.
Diffstat (limited to 'cache/filecache')
-rw-r--r-- | cache/filecache/filecache_pruner.go | 16 | ||||
-rw-r--r-- | cache/filecache/integration_test.go | 9 |
2 files changed, 3 insertions, 22 deletions
diff --git a/cache/filecache/filecache_pruner.go b/cache/filecache/filecache_pruner.go index 41aec15d3..b8aa76c15 100644 --- a/cache/filecache/filecache_pruner.go +++ b/cache/filecache/filecache_pruner.go @@ -17,8 +17,6 @@ import ( "fmt" "io" "os" - "runtime" - "strings" "github.com/gohugoio/hugo/common/herrors" "github.com/gohugoio/hugo/hugofs" @@ -73,8 +71,8 @@ func (c *Cache) Prune(force bool) (int, error) { // This cache dir may not exist. return nil } - defer f.Close() _, err = f.Readdirnames(1) + f.Close() if err == io.EOF { // Empty dir. if name == "." { @@ -82,18 +80,6 @@ func (c *Cache) Prune(force bool) (int, error) { err = nil } else { err = c.Fs.Remove(name) - if err != nil { - if runtime.GOOS == "windows" { - if strings.Contains(err.Error(), "used by another process") { - // See https://github.com/gohugoio/hugo/issues/10781 - // This is a known issue on Windows with Go 1.20. - // There's not much we can do about it. - // So just return nil. - err = nil - - } - } - } } } diff --git a/cache/filecache/integration_test.go b/cache/filecache/integration_test.go index eaddf9da6..26653fc35 100644 --- a/cache/filecache/integration_test.go +++ b/cache/filecache/integration_test.go @@ -15,7 +15,6 @@ package filecache_test import ( "path/filepath" - "runtime" "testing" "time" @@ -90,12 +89,8 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA b.Assert(b.GCCount, qt.Equals, 1) // Build it again to GC the empty a dir. b.Build() - if runtime.GOOS != "windows" { - // See issue #58860 -- this sometimes fails on Windows, - // but the empty directory will be removed on the next run. - _, err = b.H.BaseFs.ResourcesCache.Stat(filepath.Join(imagesCacheDir, "a")) - b.Assert(err, qt.Not(qt.IsNil)) - } + _, err = b.H.BaseFs.ResourcesCache.Stat(filepath.Join(imagesCacheDir, "a")) + b.Assert(err, qt.Not(qt.IsNil)) _, err = b.H.BaseFs.ResourcesCache.Stat(imagesCacheDir) b.Assert(err, qt.IsNil) |