Handle SSM cache miss when rendering markdown.

SSM cache misses are possible when rendering markdown on print or offline calls as these calls can be made long after the slideshow itself has been rendered in the browser. To ensure YAML config options are always applied on rendering reconstitute SSM from YAML-on-disk if a cache miss occurs.
This commit is contained in:
David Russell 2016-09-29 16:37:15 +07:00
parent e05061ff0d
commit b294a7c46c

View File

@ -322,10 +322,25 @@ public class GitService {
if (downStatus == STATUS_OK) {
String ssmKey = SlideshowModel.genKey(pp);
Optional<SlideshowModel> ssm =
Optional<SlideshowModel> ssmo =
Optional.ofNullable(pitchCache.get(ssmKey));
/*
* The SSM in the pitchCache can be absent if
* we are currently processing a print or offline
* download. In these caes, quickly reconstitute
* the SSM using YAML on disk so markdown rendering
* can honor all custom YAML configurations.
*/
if(!ssmo.isPresent()) {
SlideshowModel ssm =
SlideshowModel.build(pp, true, grsService, diskService);
ssmo = Optional.of(ssm);
}
MarkdownRenderer mrndr = MarkdownRenderer.build(pp,
ssm, grsService, diskService);
ssmo, grsService, diskService);
// MarkdownModel mdm = MarkdownModel.consume(mrndr);
MarkdownModel mdm =