diff --git a/archivebox/archive.py b/archivebox/archive.py index 0e572f81..ff4490c1 100755 --- a/archivebox/archive.py +++ b/archivebox/archive.py @@ -112,6 +112,11 @@ def update_archive(archive_path, links, source=None, resume=None, append=True): archive_link(link_dir, link) except (KeyboardInterrupt, SystemExit, Exception) as e: + if isinstance(e, KeyboardInterrupt): + # Step 4: Re-write links index with updated titles, icons, and resources + all_links, _ = load_links(archive_path=out_dir) + write_links_index(out_dir=out_dir, links=all_links, finished=True) + print() print('\n{lightyellow}[X] [{now}] Downloading paused on link {timestamp} ({idx}/{total}){reset}'.format( **ANSI, now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'), @@ -217,4 +222,4 @@ if __name__ == '__main__': # Step 4: Re-write links index with updated titles, icons, and resources all_links, _ = load_links(archive_path=out_dir) - write_links_index(out_dir=out_dir, links=all_links) + write_links_index(out_dir=out_dir, links=all_links, finished=True) diff --git a/archivebox/index.py b/archivebox/index.py index 5348ab3d..8b4e8a4e 100644 --- a/archivebox/index.py +++ b/archivebox/index.py @@ -27,7 +27,7 @@ from util import ( ### Homepage index for all the links -def write_links_index(out_dir, links): +def write_links_index(out_dir, links, finished=False): """create index.html file for a given list of links""" check_links_structure(links) @@ -35,14 +35,14 @@ def write_links_index(out_dir, links): if not os.path.exists(out_dir): os.makedirs(out_dir) - print('{green}[*] [{}] Updating main index files...{reset}'.format( + print('{green}[*] [{}] Saving main index files...{reset}'.format( datetime.now().strftime('%Y-%m-%d %H:%M:%S'), **ANSI, )) write_json_links_index(out_dir, links) print(' > {}/index.json'.format(pretty_path(out_dir))) - write_html_links_index(out_dir, links) + write_html_links_index(out_dir, links, finished=finished) print(' > {}/index.html'.format(pretty_path(out_dir))) @@ -78,7 +78,7 @@ def parse_json_links_index(out_dir): return [] -def write_html_links_index(out_dir, links): +def write_html_links_index(out_dir, links, finished=False): """write the html link index to a given path""" check_links_structure(links) @@ -109,6 +109,7 @@ def write_html_links_index(out_dir, links): 'git_sha': GIT_SHA, 'short_git_sha': GIT_SHA[:8], 'rows': link_rows, + 'status': 'finished' if finished else 'running', } with open(path, 'w', encoding='utf-8') as f: diff --git a/archivebox/templates/index.html b/archivebox/templates/index.html index 50440514..13777ce3 100644 --- a/archivebox/templates/index.html +++ b/archivebox/templates/index.html @@ -100,7 +100,7 @@ } -
+