Closed LokiMidgard closed 9 years ago
I haven't experienced this myself (which is interesting), but think I know what's going on. To try and reduce the memory footprint, ReadFiles does use a stream instead of loading the files into memory. However, downstream modules can cause that stream to get disposed of they clone the document with new content (which explains why you don't get locked on Razor or Markdown files).
What I don't understand is why the CSS files are staying locked. The stream should get disposed after the pipelines are done, even if staying around in preview mode. Are you trying to edit the CSS files while the engine is still running a generation, or is this after it's done and you're just in preview mode?
It may have something to do with not disposing the Engine while previewing. I'll take a look at this soon too.
I waited until the build finished. I also set a breakpoint in the dispose method of document. The only FileStreams that where associated with css files that got disposed was output....\bootstrap.css and output....\custom.css.
the input css haven't got disposed.
I'm having a hard time replicating this one. I'll keep trying, but in the meantime, could you send over the config file that seems to trigger this problem? That should help me better replicate what you've got going on. Thanks.
I have a repository on github. I start the wyam process from within Visual Studio or Visual Studio Code. There is a Task (preview) for vs code to start and run the test server. On my system this does the job.
The file that can't be edited is static\css\custom.cs
. I hope you can reproduce the problem. If not, things getting interesting. (=_ = )
That repo is great, thanks. I'll pull it down and start testing. I spent some time looking over the document disposal logic trying to find some obvious bug, but came up blank. I'm guessing it's probably a subtle thing having to do with the sequence of modules and pipelines, so having your config will help a lot.
Excellent! I can now reproduce with your repo. That should give me enough to go on and figure out what's going on.
A minimal case that causes the problem (this is all that's needed to trigger it):
Pipelines.Add("staticInput",
ReadFiles(@"static\*"),
Meta("TargetFile", (@doc, @ctx)=>
{
return "test";
})
);
To early to tell what the exact problem is yet.
Some files I have in my project I can't edit while running
--preview
. Normally that are files I don't process like css. While I have no Problem editing.cshtml
or.md
files css files are problematic.The problem seems to be that read modules opens a stream which get disposed when ReadFiles will get disposed. But I'm not sure why this doesn't happen for other files. I haven't understood the howl Module and Document Lifecycle with caching yet.
I could stop this behavior using
File.ReadAllText()
instead ofFile.Open()
. But I'm not sure if using a string instead of stream lead to other unwanted behavior.