diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2023-04-02 12:07:14 +0200 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2023-04-02 12:07:14 +0200 |
| commit | e017fe9eb22e41b5345b919f384a0001f07784fd (patch) | |
| tree | 836a54ff0daf4249bc8332a5d2b22633d68837f5 /src/works | |
| parent | 5f3742aca70a3a21a0e88dc8737cf5c8d6b5e786 (diff) | |
Change update conditions order to check for HTML existence first
Diffstat (limited to 'src/works')
| -rw-r--r-- | src/works/stories.rs | 22 |
1 files 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<bool> { - // 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 |
