1
0
Fork 0
mirror of synced 2024-06-26 10:00:19 +12:00

fix: Issue with oneshot command

This commit is contained in:
Cristian 2020-12-07 15:39:44 -05:00 committed by Cristian Vargas
parent 876c269513
commit f6c73f9aeb
3 changed files with 9 additions and 3 deletions

View file

@ -111,9 +111,9 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
link.history[method_name].append(result)
stats[result.status] += 1
write_search_index(link=link, texts=result.index_texts)
log_archive_method_finished(result)
if not skip_index:
write_search_index(link=link, texts=result.index_texts)
ArchiveResult.objects.create(snapshot=snapshot, extractor=method_name, cmd=result.cmd, cmd_version=result.cmd_version,
output=result.output, pwd=result.pwd, start_ts=result.start_ts, end_ts=result.end_ts, status=result.status)

View file

@ -9,6 +9,7 @@ DO NOT ADD ANY NEW FEATURES TO THIS FILE, NEW CODE GOES HERE: core/models.py
__package__ = 'archivebox.index'
from pathlib import Path
from django.db.utils import OperationalError
from datetime import datetime, timedelta
@ -352,7 +353,12 @@ class Link:
### Archive Status Helpers
@property
def num_outputs(self) -> int:
return self.as_snapshot().num_outputs
try:
return self.as_snapshot().num_outputs
except OperationalError:
return sum(1 for method in self.history.keys()
for result in self.history[method]
if result.status == 'succeeded')
@property
def num_failures(self) -> int:

View file

@ -7,7 +7,7 @@ def test_oneshot_command_exists(tmp_path, disable_extractors_dict):
process = subprocess.run(['archivebox', 'oneshot'], capture_output=True, env=disable_extractors_dict)
assert not "invalid choice: 'oneshot'" in process.stderr.decode("utf-8")
def test_oneshot_commad_saves_page_in_right_folder(tmp_path, disable_extractors_dict):
def test_oneshot_command_saves_page_in_right_folder(tmp_path, disable_extractors_dict):
disable_extractors_dict.update({"SAVE_DOM": "true"})
process = subprocess.run(["archivebox", "oneshot", f"--out-dir={tmp_path}", "http://127.0.0.1:8080/static/example.com.html"],
capture_output=True, env=disable_extractors_dict)