mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Revert "Revert "Allow rendering static files to disk and dynamic to memory in server mode""
This reverts commit 64b7b7a897
.
This commit is contained in:
@@ -71,6 +71,9 @@ type BaseFs struct {
|
||||
// A read-only filesystem starting from the project workDir.
|
||||
WorkDir afero.Fs
|
||||
|
||||
// The filesystem used for renderStaticToDisk.
|
||||
PublishFsStatic afero.Fs
|
||||
|
||||
theBigFs *filesystemsCollector
|
||||
|
||||
// Locks.
|
||||
@@ -438,15 +441,17 @@ func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) err
|
||||
|
||||
publishFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Destination, p.AbsPublishDir))
|
||||
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)
|
||||
|
||||
b := &BaseFs{
|
||||
SourceFs: sourceFs,
|
||||
WorkDir: workDir,
|
||||
PublishFs: publishFs,
|
||||
buildMu: lockedfile.MutexAt(filepath.Join(p.WorkingDir, lockFileBuild)),
|
||||
SourceFs: sourceFs,
|
||||
WorkDir: workDir,
|
||||
PublishFs: publishFs,
|
||||
PublishFsStatic: publishFsStatic,
|
||||
buildMu: lockedfile.MutexAt(filepath.Join(p.WorkingDir, lockFileBuild)),
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
|
@@ -33,9 +33,10 @@ func newPagesProcessor(h *HugoSites, sp *source.SourceSpec) *pagesProcessor {
|
||||
procs := make(map[string]pagesCollectorProcessorProvider)
|
||||
for _, s := range h.Sites {
|
||||
procs[s.Lang()] = &sitePagesProcessor{
|
||||
m: s.pageMap,
|
||||
errorSender: s.h,
|
||||
itemChan: make(chan any, config.GetNumWorkerMultiplier()*2),
|
||||
m: s.pageMap,
|
||||
errorSender: s.h,
|
||||
itemChan: make(chan interface{}, config.GetNumWorkerMultiplier()*2),
|
||||
renderStaticToDisk: h.Cfg.GetBool("renderStaticToDisk"),
|
||||
}
|
||||
}
|
||||
return &pagesProcessor{
|
||||
@@ -118,6 +119,8 @@ type sitePagesProcessor struct {
|
||||
ctx context.Context
|
||||
itemChan chan any
|
||||
itemGroup *errgroup.Group
|
||||
|
||||
renderStaticToDisk bool
|
||||
}
|
||||
|
||||
func (p *sitePagesProcessor) Process(item any) error {
|
||||
@@ -162,7 +165,12 @@ func (p *sitePagesProcessor) copyFile(fim hugofs.FileMetaInfo) error {
|
||||
|
||||
defer f.Close()
|
||||
|
||||
return s.publish(&s.PathSpec.ProcessingStats.Files, target, f)
|
||||
fs := s.PublishFs
|
||||
if p.renderStaticToDisk {
|
||||
fs = s.PublishFsStatic
|
||||
}
|
||||
|
||||
return s.publish(&s.PathSpec.ProcessingStats.Files, target, f, fs)
|
||||
}
|
||||
|
||||
func (p *sitePagesProcessor) doProcess(item any) error {
|
||||
|
@@ -1829,10 +1829,10 @@ func (s *Site) lookupTemplate(layouts ...string) (tpl.Template, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (s *Site) publish(statCounter *uint64, path string, r io.Reader) (err error) {
|
||||
func (s *Site) publish(statCounter *uint64, path string, r io.Reader, fs afero.Fs) (err error) {
|
||||
s.PathSpec.ProcessingStats.Incr(statCounter)
|
||||
|
||||
return helpers.WriteToDisk(filepath.Clean(path), r, s.BaseFs.PublishFs)
|
||||
return helpers.WriteToDisk(filepath.Clean(path), r, fs)
|
||||
}
|
||||
|
||||
func (s *Site) kindFromFileInfoOrSections(fi *fileInfo, sections []string) string {
|
||||
|
Reference in New Issue
Block a user