Split out the puthe path/filepath functions into common/paths

So they can be used from the config package without cyclic troubles.

Updates #8654
This commit is contained in:
Bjørn Erik Pedersen
2021-06-18 10:27:27 +02:00
parent 5af045ebab
commit 93aad3c543
21 changed files with 956 additions and 591 deletions

View File

@@ -29,6 +29,8 @@ import (
"strings"
"sync"
"github.com/gohugoio/hugo/common/paths"
"github.com/disintegration/gift"
"github.com/gohugoio/hugo/cache/filecache"
@@ -365,7 +367,7 @@ func (i *imageResource) getImageMetaCacheTargetPath() string {
if fi := i.getFileInfo(); fi != nil {
df.dir = filepath.Dir(fi.Meta().Path())
}
p1, _ := helpers.FileAndExt(df.file)
p1, _ := paths.FileAndExt(df.file)
h, _ := i.hash()
idStr := helpers.HashString(h, i.size(), imageMetaVersionNumber, cfgHash)
p := path.Join(df.dir, fmt.Sprintf("%s_%s.json", p1, idStr))
@@ -373,7 +375,7 @@ func (i *imageResource) getImageMetaCacheTargetPath() string {
}
func (i *imageResource) relTargetPathFromConfig(conf images.ImageConfig) dirFile {
p1, p2 := helpers.FileAndExt(i.getResourcePaths().relTargetDirFile.file)
p1, p2 := paths.FileAndExt(i.getResourcePaths().relTargetDirFile.file)
if conf.TargetFormat != i.Format {
p2 = conf.TargetFormat.DefaultExtension()
}