Skip to content

Commit c7e2cc0

Browse files
fix: support "dummy" works for orphaned editions (internetarchive#11089)
* support dummy works for orphaned editions * Use WorkSolrUpdater logic to create fake work for orphans --------- Co-authored-by: Drini Cami <[email protected]>
1 parent a267d95 commit c7e2cc0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

openlibrary/solr/update.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import json
33
import logging
4+
import re
45
from pathlib import Path
56
from typing import Literal, cast
67

@@ -92,7 +93,13 @@ def _solr_update(update_state: SolrUpdateRequest):
9293
for key in updater_keys:
9394
logger.debug(f"processing {key}")
9495
try:
95-
thing = await data_provider.get_document(key)
96+
fake_work = re.fullmatch(r'^/works/(OL\d+M)$', key)
97+
if fake_work and isinstance(updater, WorkSolrUpdater):
98+
# This is a "fake" work key made from processing an orphaned edition. We know this doesn't exist, don't try to fetch it.
99+
real_key = f"/books/{fake_work.group(1)}"
100+
thing = await data_provider.get_document(real_key)
101+
else:
102+
thing = await data_provider.get_document(key)
96103

97104
if thing and thing['type']['key'] == '/type/redirect':
98105
logger.warning("Found redirect to %r", thing['location'])

0 commit comments

Comments
 (0)