Statiq.Web icon indicating copy to clipboard operation
Statiq.Web copied to clipboard

Feature Request: exclude certain files when cleaning the output path

Open SilentSin opened this issue 5 years ago • 5 comments

To commit a site to GitHub I currently have to delete everything in the repository folder except the Readme.md file and .git folder, then copy the contents of the Wyam output directory in.

It would be nice if I could just specify something like Settings[Keys.CleanOutputPathExcept] = { "Readme.md", ".git" }; to have it clean everything else but leave those files alone when I rebuild so I can directly commit the output directory without needing to manually copy anything.

SilentSin avatar Mar 21 '19 10:03 SilentSin

Great idea

daveaglick avatar Mar 22 '19 20:03 daveaglick

Another related suggestion: would it be possible to clean old files at the end of a build instead of the start so that the preview server can keep working properly while rebuilding? I imagine this could create potential issues with custom pipelines so maybe it should be optional.

SilentSin avatar Dec 13 '19 02:12 SilentSin

Another great thought. My first reaction is that it would make it hard to tell what to delete when the second build is done - if we leave all the stuff from the first build hanging around, we'd have to somehow keep track of which files weren't output by the second build and thus should be removed. Certainly not impossible, but might present a small challenge. Another potential way to do it is some sort of blue/green output - do the second build into a different, fresh output folder and then either merge it in quickly when done (deleting old files at that time) or play folder rename games before deleting the old one.

daveaglick avatar Dec 13 '19 03:12 daveaglick

I had two options in mind:

  • If all file writing is done through your APIs, you could just keep a HashSet of all file paths that have been written.
  • Or you could compare the date modified of each file to the start of the build.

A combination of both might be more efficient since checking a HashSet will be far faster than getting the date modified.

But building into a temp or build in progress folder then merging it with output at the end sounds like it could be even better.

SilentSin avatar Dec 13 '19 03:12 SilentSin

Thinking about it a bit more, is there any possibility of only rebuilding files that are actually changed? Most changes to a file outside of its front matter shouldn't affect any other files and that would avoid the issue of not being able to refresh while rebuilding by simply making the rebuild much faster. I guess custom pipelines could potentially break it, but it could always be disabled with a config option.

SilentSin avatar Dec 14 '19 08:12 SilentSin