From e017fe9eb22e41b5345b919f384a0001f07784fd Mon Sep 17 00:00:00 2001 From: WriterV2 Date: Sun, 2 Apr 2023 12:07:14 +0200 Subject: Change update conditions order to check for HTML existence first --- src/works/stories.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/works/stories.rs b/src/works/stories.rs index 9d061f6..6f21aa4 100644 --- a/src/works/stories.rs +++ b/src/works/stories.rs @@ -45,19 +45,19 @@ impl super::Works for Stories { impl Story { // check if it's necessary to re-compile the html single page fn update_available(&self) -> anyhow::Result { - // pdf document changes anyhow::Ok( - std::fs::metadata(format!("docs/stories/{}", &self.path_to_document))?.modified()? + // HTML file doesn't exist yet + !std::path::Path::new(&self.get_html_path()).exists() + // pdf document changes + || std::fs::metadata(format!("docs/stories/{}", &self.path_to_document))?.modified()? > std::fs::metadata(self.get_html_path())?.modified()? - // base template changes - || std::fs::metadata("templates/base.html")?.modified()? - > std::fs::metadata(self.get_html_path())?.modified()? - // story template changes - ||std::fs::metadata("templates/story.html")?.modified()? > std::fs::metadata(self.get_html_path())?.modified()? - // HTML file doesn't exist yet - || !std::path::Path::new(&self.get_html_path()).exists() - // add error context - ).with_context(|| format!("Failed to check for update for {}", self.title)) + // base template changes + || std::fs::metadata("templates/base.html")?.modified()? + > std::fs::metadata(self.get_html_path())?.modified()? + // story template changes + ||std::fs::metadata("templates/story.html")?.modified()? > std::fs::metadata(self.get_html_path())?.modified()?, // add error context + ) + .with_context(|| format!("Failed to check for update for {}", self.title)) } // use story document name for the single page -- cgit v1.2.3