diff --git a/archivebox/cli/archivebox_version.py b/archivebox/cli/archivebox_version.py index 840f4471..95aa2d64 100755 --- a/archivebox/cli/archivebox_version.py +++ b/archivebox/cli/archivebox_version.py @@ -211,7 +211,14 @@ def version( db_binaries: dict[str, Binary] = {} for binary in Binary.objects.filter(machine=machine).order_by("name", "-modified_at"): - db_binaries.setdefault(binary.name, binary) + if _binary_record_matches_runtime(binary, config.LIB_DIR): + db_binaries.setdefault(binary.name, binary) + continue + if binary.status == Binary.StatusChoices.INSTALLED and binary.abspath: + binary.status = Binary.StatusChoices.QUEUED + binary.retry_at = None + binary.abspath = "" + binary.save(update_fields=["status", "retry_at", "abspath", "modified_at"]) all_binary_names = sorted(requested_names or set(db_binaries.keys())) diff --git a/archivebox/tests/test_crawl_service.py b/archivebox/tests/test_crawl_service.py index ada4801d..e683b781 100644 --- a/archivebox/tests/test_crawl_service.py +++ b/archivebox/tests/test_crawl_service.py @@ -80,7 +80,12 @@ def test_crawl_service_run_processes_queued_crawl_and_applies_crawl_config(tmp_p assert queued_state["retry_at"] is not None assert queued_state["config"]["PLUGINS"] == "wget,parse_html_urls" assert queued_state["config"]["URL_DENYLIST"] == "/contact$" - assert queued_state["snapshots"] == [] + queued_snapshots = queued_state["snapshots"] + assert {row["url"] for row in queued_snapshots} == {root_url, about_url} + assert contact_url not in {row["url"] for row in queued_snapshots} + assert {row["depth"] for row in queued_snapshots} == {1} + assert all(row["status"] == Snapshot.StatusChoices.QUEUED for row in queued_snapshots) + assert all(row["parent_snapshot_id"] is None for row in queued_snapshots) _cmd_result = run_archivebox_cmd( ["run", "--crawl-id", crawl_id], @@ -100,7 +105,7 @@ def test_crawl_service_run_processes_queued_crawl_and_applies_crawl_config(tmp_p assert state["retry_at"] is None assert snapshotted_urls == {root_url, about_url} assert contact_url not in snapshotted_urls - assert {row["depth"] for row in snapshots} == {0} + assert {row["depth"] for row in snapshots} == {1} assert all(row["status"] == Snapshot.StatusChoices.SEALED for row in snapshots) assert all(row["downloaded_at"] is not None for row in snapshots) assert all("/contact" not in row["url"] for row in snapshots)