Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/hugofs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-01-22 13:57:23 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-01-23 13:50:02 +0300
commit17af79a03e249a731cf5634ffea23ca00774333d (patch)
tree66596a159aa57c948f1ffe272e5cd8ab86c7c1bf /hugofs
parent2fefc01606fddb119f368c89fb2dedd452ad6547 (diff)
Fix 0.62.1 server rebuild slowdown regression
Fixes #6784
Diffstat (limited to 'hugofs')
-rw-r--r--hugofs/fileinfo.go28
-rw-r--r--hugofs/rootmapping_fs.go6
-rw-r--r--hugofs/rootmapping_fs_test.go2
3 files changed, 11 insertions, 25 deletions
diff --git a/hugofs/fileinfo.go b/hugofs/fileinfo.go
index 893436df1..c8a71bf21 100644
--- a/hugofs/fileinfo.go
+++ b/hugofs/fileinfo.go
@@ -34,9 +34,9 @@ import (
)
const (
- metaKeyFilename = "filename"
- metaKeyPathFile = "pathFile" // Path of filename relative to a root.
- metaKeyIsFileMount = "isFileMount" // Whether the source mount was a file.
+ metaKeyFilename = "filename"
+
+ metaKeyBaseDir = "baseDir" // Abs base directory of source file.
metaKeyMountRoot = "mountRoot"
metaKeyOriginalFilename = "originalFilename"
metaKeyName = "name"
@@ -116,29 +116,19 @@ func (f FileMeta) Path() string {
return f.stringV(metaKeyPath)
}
-// PathFile returns the relative file path for the file source. This
-// will in most cases be the same as Path.
+// PathFile returns the relative file path for the file source.
func (f FileMeta) PathFile() string {
- pf := f.stringV(metaKeyPathFile)
- if f.isFileMount() {
- return pf
- }
- mountRoot := f.mountRoot()
- if mountRoot == pf {
- return f.Path()
+ base := f.stringV(metaKeyBaseDir)
+ if base == "" {
+ return ""
}
-
- return pf + (strings.TrimPrefix(f.Path(), mountRoot))
+ return strings.TrimPrefix(strings.TrimPrefix(f.Filename(), base), filepathSeparator)
}
-func (f FileMeta) mountRoot() string {
+func (f FileMeta) MountRoot() string {
return f.stringV(metaKeyMountRoot)
}
-func (f FileMeta) isFileMount() bool {
- return f.GetBool(metaKeyIsFileMount)
-}
-
func (f FileMeta) Weight() int {
return f.GetInt(metaKeyWeight)
}
diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go
index dd60452fc..2196be8e0 100644
--- a/hugofs/rootmapping_fs.go
+++ b/hugofs/rootmapping_fs.go
@@ -57,12 +57,8 @@ func NewRootMappingFs(fs afero.Fs, rms ...RootMapping) (*RootMappingFs, error) {
// Extract "blog" from "content/blog"
rm.path = strings.TrimPrefix(strings.TrimPrefix(rm.From, fromBase), filepathSeparator)
if rm.Meta != nil {
- rm.Meta[metaKeyIsFileMount] = !fi.IsDir()
+ rm.Meta[metaKeyBaseDir] = rm.ToBasedir
rm.Meta[metaKeyMountRoot] = rm.path
- if rm.ToBasedir != "" {
- pathFile := strings.TrimPrefix(strings.TrimPrefix(rm.To, rm.ToBasedir), filepathSeparator)
- rm.Meta[metaKeyPathFile] = pathFile
- }
}
meta := copyFileMeta(rm.Meta)
diff --git a/hugofs/rootmapping_fs_test.go b/hugofs/rootmapping_fs_test.go
index 7d685c77e..f7637a61f 100644
--- a/hugofs/rootmapping_fs_test.go
+++ b/hugofs/rootmapping_fs_test.go
@@ -271,7 +271,7 @@ func TestRootMappingFsMount(t *testing.T) {
c.Assert(singles, qt.HasLen, 2)
for i, lang := range []string{"no", "sv"} {
fi := singles[i].(FileMetaInfo)
- c.Assert(fi.Meta().PathFile(), qt.Equals, lang+".txt")
+ c.Assert(fi.Meta().PathFile(), qt.Equals, filepath.FromSlash("themes/a/singlefiles/"+lang+".txt"))
c.Assert(fi.Meta().Lang(), qt.Equals, lang)
c.Assert(fi.Name(), qt.Equals, "p1.md")
}