Closed ewft closed 1 year ago
Hi Ben,
Thank you for your bug report.
This is because the content of each script is hashed, and the hash determines the filename. This means that two scripts with the same content will be exported to the same file, as you pointed out.
The reason for this was to prevent pandoc-plot
from re-generating plots on large documents. So if I change a single plot script in a 500 pages book, only 1 plot will be re-generated. If pandoc-plot added a randomly-generated string to every plot, then I would lose the 'caching' feature.
If you have N identical plot scripts (all with an identical hash value), then pandoc-plot
could generate only 1 figure. Then, in the final document, you would have N links to the same file. Would that solution work for you?
I've opted for the crude fix for now: add a lock to file writing operations. Most of the time is spent rendering figures anyways, so this lock won't have much effect on performance.
Once the tests pass, including a new one replicating the issue you reported, I'll make a new release.
Version 1.5.5 has just been released. It should fix your issue. Please give it a try and let me know how it goes.
I'll close this for now, as version 1.5.5 should fix this issue. If not, please don't hesitate to re-open the issue.
Hi,
I found out that if a document contains multiple identical plots ( exactly same source code to generate the plot), pandoc-plot fail ( in a random way) over a race condition on the created files.
pandoc-plot: plots/pandocplot12097460476205103681.src.html: withFile: resource busy (file is locked).
I work around this by adding some random comment different in each plot code source.
I run across that issue when dealing with automated generated document (Test report) with identical plots ( basic pie chart showing the test results (PASS/FAIL).
I think this could be solve by adding a random part in the calculation of the plot ID. And probably conditioned by an option to not impact performance when not needed.