X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=remove_old_html.py;h=bbddded89f3580c960ef45aa26fe8477e34be21e;hb=HEAD;hp=904ff9eb8a6d934e3c63bcb4a1bfbf51eba2cad7;hpb=e968f29c9bd237139cd9a7f662562f69ecdc057c;p=phdru.name%2Fphdru.name.git 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)