diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-14 16:02:04 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-04-08 13:26:16 +0200 |
commit | 0a56f2af4e1969e76e94fdfb56d1bbed0e685625 (patch) | |
tree | db258649317ea350ce6c56f00483d5655963de16 /commands/commandeer.go | |
parent | 9e360d3844f5077c65649e4c9c98f5cbd1c3efc0 (diff) |
Revert "Revert "Allow rendering static files to disk and dynamic to memory in server mode""
This reverts commit 64b7b7a89753a39661219b2fcb92d7f185a03f63.
Diffstat (limited to 'commands/commandeer.go')
-rw-r--r-- | commands/commandeer.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index 8a1925893..6f74bf864 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -94,6 +94,7 @@ type commandeer struct { languagesConfigured bool languages langs.Languages doLiveReload bool + renderStaticToDisk bool fastRenderMode bool showErrorInBrowser bool wasError bool @@ -375,8 +376,9 @@ func (c *commandeer) loadConfig() error { } createMemFs := config.GetBool("renderToMemory") + c.renderStaticToDisk = config.GetBool("renderStaticToDisk") - if createMemFs { + if createMemFs && !c.renderStaticToDisk { // Rendering to memoryFS, publish to Root regardless of publishDir. config.Set("publishDir", "/") } @@ -387,6 +389,14 @@ func (c *commandeer) loadConfig() error { if c.destinationFs != nil { // Need to reuse the destination on server rebuilds. fs.Destination = c.destinationFs + } else if createMemFs && c.renderStaticToDisk { + // Writes the dynamic output on memory, + // while serve others directly from publishDir + publishDir := config.GetString("publishDir") + writableFs := afero.NewBasePathFs(afero.NewMemMapFs(), publishDir) + publicFs := afero.NewOsFs() + fs.Destination = afero.NewCopyOnWriteFs(afero.NewReadOnlyFs(publicFs), writableFs) + fs.DestinationStatic = publicFs } else if createMemFs { // Hugo writes the output to memory instead of the disk. fs.Destination = new(afero.MemMapFs) @@ -404,11 +414,13 @@ func (c *commandeer) loadConfig() error { changeDetector.PrepareNew() fs.Destination = hugofs.NewHashingFs(fs.Destination, changeDetector) + fs.DestinationStatic = hugofs.NewHashingFs(fs.DestinationStatic, changeDetector) c.changeDetector = changeDetector } if c.Cfg.GetBool("logPathWarnings") { fs.Destination = hugofs.NewCreateCountingFs(fs.Destination) + fs.DestinationStatic = hugofs.NewCreateCountingFs(fs.DestinationStatic) } // To debug hard-to-find path issues. |