From b294a7c46c1593279e79c579cef16eec475ec24b Mon Sep 17 00:00:00 2001 From: David Russell Date: Thu, 29 Sep 2016 16:37:15 +0700 Subject: [PATCH] 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. --- app/com/gitpitch/services/GitService.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/com/gitpitch/services/GitService.java b/app/com/gitpitch/services/GitService.java index db1d6a9..319c87a 100644 --- a/app/com/gitpitch/services/GitService.java +++ b/app/com/gitpitch/services/GitService.java @@ -322,10 +322,25 @@ public class GitService { if (downStatus == STATUS_OK) { String ssmKey = SlideshowModel.genKey(pp); - Optional ssm = + Optional 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 =