From 74dd560979934af134687f1b9227b3000be800f1 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 4 Oct 2018 16:38:41 +0100 Subject: [PATCH] extend caching for tikz, minted and markdown files --- .../clsi/app/coffee/ResourceWriter.coffee | 8 ++- .../unit/coffee/ResourceWriterTests.coffee | 56 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/services/clsi/app/coffee/ResourceWriter.coffee b/services/clsi/app/coffee/ResourceWriter.coffee index 1285572304..f3a4bd0735 100644 --- a/services/clsi/app/coffee/ResourceWriter.coffee +++ b/services/clsi/app/coffee/ResourceWriter.coffee @@ -78,7 +78,13 @@ module.exports = ResourceWriter = should_delete = true if path.match(/^output\./) or path.match(/\.aux$/) or path.match(/^cache\//) # knitr cache should_delete = false - if path.match(/^output-.*/) # Tikz cached figures + if path.match(/^output-.*/) # Tikz cached figures (default case) + should_delete = false + if path.match(/\.(pdf|dpth|md5)$/) # Tikz cached figures (by extension) + should_delete = false + if path.match(/\.(pygtex|pygstyle)$/) or path.match(/(^|\/)_minted-[^\/]+\//) # minted files/directory + should_delete = false + if path.match(/\.md\.tex$/) or path.match(/(^|\/)_markdown_[^\/]+\//) # markdown files/directory should_delete = false if path.match(/-eps-converted-to\.pdf$/) # Epstopdf generated files should_delete = false diff --git a/services/clsi/test/unit/coffee/ResourceWriterTests.coffee b/services/clsi/test/unit/coffee/ResourceWriterTests.coffee index 66a8a36d96..4a88226f20 100644 --- a/services/clsi/test/unit/coffee/ResourceWriterTests.coffee +++ b/services/clsi/test/unit/coffee/ResourceWriterTests.coffee @@ -137,6 +137,27 @@ describe "ResourceWriter", -> },{ path: "figures/image-eps-converted-to.pdf" type: "pdf" + },{ + path: "foo/main-figure0.md5" + type: "md5" + }, { + path: "foo/main-figure0.dpth" + type: "dpth" + }, { + path: "foo/main-figure0.pdf" + type: "pdf" + }, { + path: "_minted-main/default-pyg-prefix.pygstyle" + type: "pygstyle" + }, { + path: "_minted-main/default.pygstyle" + type: "pygstyle" + }, { + path: "_minted-main/35E248B60965545BD232AE9F0FE9750D504A7AF0CD3BAA7542030FC560DFCC45.pygtex" + type: "pygtex" + }, { + path: "_markdown_main/30893013dec5d869a415610079774c2f.md.tex" + type: "tex" }] @resources = "mock-resources" @OutputFileFinder.findOutputFiles = sinon.stub().callsArgWith(2, null, @output_files) @@ -173,6 +194,41 @@ describe "ResourceWriter", -> .calledWith(path.join(@basePath, "figures/image-eps-converted-to.pdf")) .should.equal false + it "should not delete the tikz md5 files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "foo/main-figure0.md5")) + .should.equal false + + it "should not delete the tikz dpth files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "foo/main-figure0.dpth")) + .should.equal false + + it "should not delete the tikz pdf files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "foo/main-figure0.pdf")) + .should.equal false + + it "should not delete the minted pygstyle files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "_minted-main/default-pyg-prefix.pygstyle")) + .should.equal false + + it "should not delete the minted default pygstyle files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "_minted-main/default.pygstyle")) + .should.equal false + + it "should not delete the minted default pygtex files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "_minted-main/35E248B60965545BD232AE9F0FE9750D504A7AF0CD3BAA7542030FC560DFCC45.pygtex")) + .should.equal false + + it "should not delete the markdown md.tex files", -> + @ResourceWriter._deleteFileIfNotDirectory + .calledWith(path.join(@basePath, "_markdown_main/30893013dec5d869a415610079774c2f.md.tex")) + .should.equal false + it "should call the callback", -> @callback.called.should.equal true