mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 13:40:38 +03:00
parent
32471b57bd
commit
d90e37e0c6
442 changed files with 1426 additions and 2254 deletions
5
cache/filecache/filecache.go
vendored
5
cache/filecache/filecache.go
vendored
|
@ -158,7 +158,6 @@ func (c *Cache) ReadOrCreate(id string,
|
|||
err = create(info, f)
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
// GetOrCreate tries to get the file with the given id from cache. If not found or expired, create will
|
||||
|
@ -220,7 +219,6 @@ func (c *Cache) GetOrCreateBytes(id string, create func() ([]byte, error)) (Item
|
|||
return info, nil, err
|
||||
}
|
||||
return info, b, nil
|
||||
|
||||
}
|
||||
|
||||
// GetBytes gets the file content with the given id from the cahce, nil if none found.
|
||||
|
@ -276,7 +274,6 @@ func (c *Cache) getOrRemove(id string) hugio.ReadSeekCloser {
|
|||
}
|
||||
|
||||
f, err := c.Fs.Open(id)
|
||||
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -299,7 +296,6 @@ func (c *Cache) getString(id string) string {
|
|||
defer c.nlocker.Unlock(id)
|
||||
|
||||
f, err := c.Fs.Open(id)
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
@ -307,7 +303,6 @@ func (c *Cache) getString(id string) string {
|
|||
|
||||
b, _ := ioutil.ReadAll(f)
|
||||
return string(b)
|
||||
|
||||
}
|
||||
|
||||
// Caches is a named set of caches.
|
||||
|
|
3
cache/filecache/filecache_config_test.go
vendored
3
cache/filecache/filecache_config_test.go
vendored
|
@ -69,7 +69,6 @@ dir = "/path/to/c3"
|
|||
c3 := decoded["images"]
|
||||
c.Assert(c3.MaxAge, qt.Equals, time.Duration(-1))
|
||||
c.Assert(c3.Dir, qt.Equals, filepath.FromSlash("/path/to/c3/filecache/images"))
|
||||
|
||||
}
|
||||
|
||||
func TestDecodeConfigIgnoreCache(t *testing.T) {
|
||||
|
@ -110,7 +109,6 @@ dir = "/path/to/c3"
|
|||
for _, v := range decoded {
|
||||
c.Assert(v.MaxAge, qt.Equals, time.Duration(0))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDecodeConfigDefault(t *testing.T) {
|
||||
|
@ -178,7 +176,6 @@ dir = "/"
|
|||
|
||||
_, err = DecodeConfig(fs, cfg)
|
||||
c.Assert(err, qt.Not(qt.IsNil))
|
||||
|
||||
}
|
||||
|
||||
func newTestConfig() *viper.Viper {
|
||||
|
|
2
cache/filecache/filecache_pruner.go
vendored
2
cache/filecache/filecache_pruner.go
vendored
|
@ -110,7 +110,6 @@ func (c *Cache) Prune(force bool) (int, error) {
|
|||
}
|
||||
|
||||
func (c *Cache) pruneRootDir(force bool) (int, error) {
|
||||
|
||||
info, err := c.Fs.Stat(c.pruneAllRootDir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -124,5 +123,4 @@ func (c *Cache) pruneRootDir(force bool) (int, error) {
|
|||
}
|
||||
|
||||
return hugofs.MakeReadableAndRemoveAllModulePkgDir(c.Fs, c.pruneAllRootDir)
|
||||
|
||||
}
|
||||
|
|
1
cache/filecache/filecache_pruner_test.go
vendored
1
cache/filecache/filecache_pruner_test.go
vendored
|
@ -107,5 +107,4 @@ dir = ":resourceDir/_gen"
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
3
cache/filecache/filecache_test.go
vendored
3
cache/filecache/filecache_test.go
vendored
|
@ -183,7 +183,6 @@ dir = ":cacheDir/c"
|
|||
c.Assert(string(b), qt.Equals, "Hugo is great!")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestFileCacheConcurrent(t *testing.T) {
|
||||
|
@ -253,7 +252,6 @@ func TestFileCacheReadOrCreateErrorInRead(t *testing.T) {
|
|||
var result string
|
||||
|
||||
rf := func(failLevel int) func(info ItemInfo, r io.ReadSeeker) error {
|
||||
|
||||
return func(info ItemInfo, r io.ReadSeeker) error {
|
||||
if failLevel > 0 {
|
||||
if failLevel > 1 {
|
||||
|
@ -347,5 +345,4 @@ func newPathsSpec(t *testing.T, fs afero.Fs, configStr string) *helpers.PathSpec
|
|||
p, err := helpers.NewPathSpec(hugofs.NewFrom(fs, cfg), cfg, nil)
|
||||
c.Assert(err, qt.IsNil)
|
||||
return p
|
||||
|
||||
}
|
||||
|
|
1
cache/namedmemcache/named_cache.go
vendored
1
cache/namedmemcache/named_cache.go
vendored
|
@ -49,7 +49,6 @@ func (c *Cache) Clear() {
|
|||
|
||||
c.cache = make(map[string]cacheEntry)
|
||||
c.nlocker = locker.NewLocker()
|
||||
|
||||
}
|
||||
|
||||
// GetOrCreate tries to get the value with the given cache key, if not found
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue