From f397634dd236b9d77d6f6da2dfd55c63b98adc9b Mon Sep 17 00:00:00 2001 From: Cristian Date: Mon, 19 Oct 2020 10:18:11 -0500 Subject: [PATCH] feat: Rename old indexes at the end of init process --- archivebox/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/archivebox/main.py b/archivebox/main.py index 918098c8..72d5009c 100644 --- a/archivebox/main.py +++ b/archivebox/main.py @@ -4,6 +4,7 @@ import os import sys import shutil from pathlib import Path +from datetime import date from typing import Dict, List, Optional, Iterable, IO, Union from crontab import CronTab, CronSlices @@ -387,6 +388,15 @@ def init(force: bool=False, out_dir: Path=OUTPUT_DIR) -> None: print(' For more usage and examples, run:') print(' archivebox help') + json_index = Path(out_dir) / JSON_INDEX_FILENAME + html_index = Path(out_dir) / HTML_INDEX_FILENAME + index_name = f"{date.today()}_index_old" + if json_index.exists(): + json_index.rename(f"{index_name}.json") + if html_index.exists(): + html_index.rename(f"{index_name}.html") + + @enforce_types def status(out_dir: Path=OUTPUT_DIR) -> None: