From: Oleg Broytman Date: Sun, 12 Dec 2021 23:16:30 +0000 (+0300) Subject: Fix(remove_old_html): Check if the blog is empty X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=fde7b6e4d87740a43c833299a27cb03bc62cc120;p=phdru.name%2Fphdru.name.git Fix(remove_old_html): Check if the blog is empty --- diff --git a/remove_old_html.py b/remove_old_html.py index 904ff9e..bbddded 100755 --- a/remove_old_html.py +++ b/remove_old_html.py @@ -1,7 +1,7 @@ #! /usr/bin/env python __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2020 PhiloSoft Design" +__copyright__ = "Copyright (C) 2020, 2021 PhiloSoft Design" import os from blog_db import blog_root, load_blog @@ -62,19 +62,20 @@ for key in sorted(blog): if current_mtime is not None and (next_mtime < current_mtime): os.remove(next_html) -current_tmpl = fullpath(key, blog_post) -try: - current_mtime = os.path.getmtime(current_tmpl) -except OSError: - pass -else: - current_mtime = None +if blog: + current_tmpl = fullpath(key, blog_post) + try: + current_mtime = os.path.getmtime(current_tmpl) + except OSError: + pass + else: + current_mtime = None -prev_html = html(fullpath(current_key, current_blog_post)) -try: - prev_mtime = os.path.getmtime(prev_html) -except OSError: - pass -else: - if current_mtime is not None and (prev_mtime < current_mtime): - os.remove(prev_html) + prev_html = html(fullpath(current_key, current_blog_post)) + try: + prev_mtime = os.path.getmtime(prev_html) + except OSError: + pass + else: + if current_mtime is not None and (prev_mtime < current_mtime): + os.remove(prev_html)