Repair stale binaries in version output

This commit is contained in:
Nick Sweeting 2026-06-11 07:52:05 -07:00
parent 33436ae646
commit 14d43c88f5
No known key found for this signature in database
2 changed files with 15 additions and 3 deletions

View File

@ -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()))

View File

@ -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)