summaryrefslogtreecommitdiffstats
path: root/hugolib/filesystems/basefs.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-21 09:35:15 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-08 13:26:17 +0200
commitd070bdf10f14d233288f7318a4e9f7555f070a65 (patch)
treefff8d59f98bdab3027bb45c4e10ca88594332872 /hugolib/filesystems/basefs.go
parentb08193971a821fc27e549a73120c15e5e5186775 (diff)
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
Diffstat (limited to 'hugolib/filesystems/basefs.go')
-rw-r--r--hugolib/filesystems/basefs.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go
index 0290d2e1c..693dd8575 100644
--- a/hugolib/filesystems/basefs.go
+++ b/hugolib/filesystems/basefs.go
@@ -38,8 +38,8 @@ import (
"github.com/gohugoio/hugo/modules"
+ hpaths "github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/hugofs"
-
"github.com/gohugoio/hugo/hugolib/paths"
"github.com/spf13/afero"
)
@@ -68,12 +68,12 @@ type BaseFs struct {
// This usually maps to /my-project/public.
PublishFs afero.Fs
- // A read-only filesystem starting from the project workDir.
- WorkDir afero.Fs
-
// The filesystem used for renderStaticToDisk.
PublishFsStatic afero.Fs
+ // A read-only filesystem starting from the project workDir.
+ WorkDir afero.Fs
+
theBigFs *filesystemsCollector
// Locks.
@@ -434,21 +434,13 @@ func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) err
logger = loggers.NewWarningLogger()
}
- // Make sure we always have the /public folder ready to use.
- if err := fs.Destination.MkdirAll(p.AbsPublishDir, 0777); err != nil && !os.IsExist(err) {
- return nil, err
- }
-
- publishFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Destination, p.AbsPublishDir))
+ publishFs := hugofs.NewBaseFileDecorator(fs.PublishDir)
sourceFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Source, p.WorkingDir))
- publishFsStatic := afero.NewBasePathFs(fs.Source, p.AbsPublishDir)
-
- // Same as sourceFs, but no decoration. This is what's used by os.ReadDir etc.
- workDir := afero.NewBasePathFs(afero.NewReadOnlyFs(fs.Source), p.WorkingDir)
+ publishFsStatic := fs.PublishDirStatic
b := &BaseFs{
SourceFs: sourceFs,
- WorkDir: workDir,
+ WorkDir: fs.WorkingDirReadOnly,
PublishFs: publishFs,
PublishFsStatic: publishFsStatic,
buildMu: lockedfile.MutexAt(filepath.Join(p.WorkingDir, lockFileBuild)),
@@ -638,7 +630,7 @@ func (b *sourceFilesystemsBuilder) createModFs(
if filepath.IsAbs(path) {
return "", path
}
- return md.dir, paths.AbsPathify(md.dir, path)
+ return md.dir, hpaths.AbsPathify(md.dir, path)
}
for i, mount := range md.Mounts() {