fix: Issue with oneshot command
This commit is contained in:
parent
876c269513
commit
f6c73f9aeb
3 changed files with 9 additions and 3 deletions
|
@ -111,9 +111,9 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
|
||||||
link.history[method_name].append(result)
|
link.history[method_name].append(result)
|
||||||
|
|
||||||
stats[result.status] += 1
|
stats[result.status] += 1
|
||||||
write_search_index(link=link, texts=result.index_texts)
|
|
||||||
log_archive_method_finished(result)
|
log_archive_method_finished(result)
|
||||||
if not skip_index:
|
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,
|
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)
|
output=result.output, pwd=result.pwd, start_ts=result.start_ts, end_ts=result.end_ts, status=result.status)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ DO NOT ADD ANY NEW FEATURES TO THIS FILE, NEW CODE GOES HERE: core/models.py
|
||||||
__package__ = 'archivebox.index'
|
__package__ = 'archivebox.index'
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from django.db.utils import OperationalError
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
@ -352,7 +353,12 @@ class Link:
|
||||||
### Archive Status Helpers
|
### Archive Status Helpers
|
||||||
@property
|
@property
|
||||||
def num_outputs(self) -> int:
|
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
|
@property
|
||||||
def num_failures(self) -> int:
|
def num_failures(self) -> int:
|
||||||
|
|
|
@ -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)
|
process = subprocess.run(['archivebox', 'oneshot'], capture_output=True, env=disable_extractors_dict)
|
||||||
assert not "invalid choice: 'oneshot'" in process.stderr.decode("utf-8")
|
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"})
|
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"],
|
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)
|
capture_output=True, env=disable_extractors_dict)
|
||||||
|
|
Loading…
Reference in a new issue