mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
Fix duplicate snapshot archive picker
This commit is contained in:
parent
df163d81d7
commit
e702e15b45
@ -575,7 +575,7 @@ class SnapshotView(View):
|
||||
slug,
|
||||
)
|
||||
+ snapshot_hrefs
|
||||
+ format_html('</pre><br/>Choose a Snapshot to proceed or go back to the <a href="/" target="_top">Main Index</a>'),
|
||||
+ mark_safe('</pre><br/>Choose a Snapshot to proceed or go back to the <a href="/" target="_top">Main Index</a>'),
|
||||
content_type="text/html",
|
||||
status=404,
|
||||
)
|
||||
@ -677,7 +677,7 @@ class SnapshotView(View):
|
||||
base_url(path),
|
||||
)
|
||||
+ snapshot_hrefs
|
||||
+ format_html('</pre><br/>Choose a Snapshot to proceed or go back to the <a href="/" target="_top">Main Index</a>'),
|
||||
+ mark_safe('</pre><br/>Choose a Snapshot to proceed or go back to the <a href="/" target="_top">Main Index</a>'),
|
||||
content_type="text/html",
|
||||
status=404,
|
||||
)
|
||||
|
||||
@ -181,6 +181,7 @@ def _create_public_snapshot_with_cli(data_dir, url: str) -> str:
|
||||
timeout=60,
|
||||
)
|
||||
assert result.returncode == 0, result.stderr or result.stdout
|
||||
|
||||
records = [json.loads(line) for line in result.stdout.splitlines() if line.strip().startswith("{")]
|
||||
assert records, result.stdout
|
||||
snapshot_id = str(records[-1]["id"])
|
||||
@ -207,6 +208,25 @@ def _create_public_snapshot_with_cli(data_dir, url: str) -> str:
|
||||
return snapshot_id
|
||||
|
||||
|
||||
@override_settings(PUBLIC_INDEX=True)
|
||||
def test_archive_url_with_multiple_snapshots_shows_snapshot_picker(client, admin_user):
|
||||
from archivebox.core.models import Snapshot
|
||||
from archivebox.crawls.models import Crawl
|
||||
|
||||
url = "https://multiple-public-snapshots.example/page"
|
||||
first_crawl = Crawl.objects.create(urls=url, created_by=admin_user, config={"PERMISSIONS": "public"})
|
||||
second_crawl = Crawl.objects.create(urls=url, created_by=admin_user, config={"PERMISSIONS": "public"})
|
||||
first = Snapshot.objects.create(url=url, title="First copy", crawl=first_crawl, status=Snapshot.StatusChoices.SEALED)
|
||||
second = Snapshot.objects.create(url=url, title="Second copy", crawl=second_crawl, status=Snapshot.StatusChoices.SEALED)
|
||||
|
||||
response = client.get(f"/archive/{url}", HTTP_HOST=WEB_TEST_HOST)
|
||||
|
||||
assert response.status_code == 404
|
||||
assert b"Multiple Snapshots match the given URL" in response.content
|
||||
assert first.archive_path.encode() in response.content
|
||||
assert second.archive_path.encode() in response.content
|
||||
|
||||
|
||||
def _login_admin_session_over_http(port: int, host: str) -> requests.Session:
|
||||
session = requests.Session()
|
||||
login_page = session.get(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user