diff --git a/archivebox/extractors/__init__.py b/archivebox/extractors/__init__.py index 7c71f241..c0e0c433 100644 --- a/archivebox/extractors/__init__.py +++ b/archivebox/extractors/__init__.py @@ -96,6 +96,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s log_link_archiving_started(link, out_dir, is_new) link = link.overwrite(updated=datetime.now(timezone.utc)) stats = {'skipped': 0, 'succeeded': 0, 'failed': 0} + start_ts = datetime.now(timezone.utc) for method_name, should_run, method_function in ARCHIVE_METHODS: try: @@ -142,7 +143,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s write_link_details(link, out_dir=out_dir, skip_sql_index=False) - log_link_archiving_finished(link, link.link_dir, is_new, stats) + log_link_archiving_finished(link, link.link_dir, is_new, stats, start_ts) except KeyboardInterrupt: try: diff --git a/archivebox/logging_util.py b/archivebox/logging_util.py index 6cb34f47..46ce2446 100644 --- a/archivebox/logging_util.py +++ b/archivebox/logging_util.py @@ -379,7 +379,7 @@ def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool): pretty_path(link_dir), )) -def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict): +def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict, start_ts: datetime): total = sum(stats.values()) if stats['failed'] > 0 : @@ -390,7 +390,9 @@ def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats _LAST_RUN_STATS.succeeded += 1 size = get_dir_size(link_dir) - print(' {black}{} files ({}){reset}'.format(size[2], printable_filesize(size[0]), **ANSI)) + end_ts = datetime.now(timezone.utc) + duration = str(end_ts - start_ts).split('.')[0] + print(' {black}{} files ({}) in {}s {reset}'.format(size[2], printable_filesize(size[0]), duration, **ANSI)) def log_archive_method_started(method: str):