Skip to content

Commit f330407

Browse files
committed
cont.
1 parent c6d3022 commit f330407

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

ckanext/datastore_search/backend/solr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def _make_connection(self, resource_id: str) -> Optional[pysolr.Solr]:
8585
"""
8686
core_name = f'{self.prefix}{resource_id}'
8787
conn_string = f'{self.url}/solr/{core_name}'
88-
conn = pysolr.Solr(conn_string, timeout=self.timeout)
8988
try:
89+
conn = pysolr.Solr(conn_string, timeout=self.timeout)
9090
resp = json.loads(conn.ping())
9191
if resp.get('status') == 'OK':
9292
return conn
@@ -267,8 +267,6 @@ def create(self,
267267
rq_kwargs={'timeout': 60})
268268
log.debug('Enqueued SOLR Core creation for DataStore Resource %s ' %
269269
resource_id)
270-
# we return here as we do not know how long the background
271-
# job to create the new SOLR core will take.
272270
return
273271
if not conn:
274272
raise DatastoreSearchException(

ckanext/datastore_search/logic/action.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
from typing import Dict, Any
21
from ckan.types import Context, DataDict, Action, ChainedAction
32

43
from ckan.plugins import toolkit
54
from ckan.lib.navl.dictization_functions import validate
65

76
from ckanext.datastore.logic.schema import datastore_search_schema
8-
from ckanext.datastore_search.backend import DatastoreSearchBackend
7+
from ckanext.datastore_search.backend import (
8+
DatastoreSearchBackend,
9+
DatastoreSearchException
10+
)
911

1012

1113
ignore_missing = toolkit.get_validator('ignore_missing')
1214
ignore_not_sysadmin = toolkit.get_validator('ignore_not_sysadmin')
1315

1416

15-
def datastore_search_create_callback(data_dict):
17+
def datastore_search_create_callback(data_dict: DataDict):
1618
backend = DatastoreSearchBackend.get_active_backend()
1719
backend.create_callback(data_dict)
1820

@@ -24,7 +26,10 @@ def datastore_create(up_func: Action,
2426
data_dict['include_records'] = True
2527
func_result = up_func(context, data_dict)
2628
backend = DatastoreSearchBackend.get_active_backend()
27-
backend.create(dict(func_result))
29+
try:
30+
backend.create(dict(func_result))
31+
except DatastoreSearchException:
32+
pass
2833
return func_result
2934

3035

@@ -35,7 +40,10 @@ def datastore_upsert(up_func: Action,
3540
data_dict['include_records'] = True
3641
func_result = up_func(context, data_dict)
3742
backend = DatastoreSearchBackend.get_active_backend()
38-
backend.upsert(dict(func_result))
43+
try:
44+
backend.upsert(dict(func_result))
45+
except DatastoreSearchException:
46+
pass
3947
return func_result
4048

4149

@@ -46,7 +54,10 @@ def datastore_delete(up_func: Action,
4654
data_dict['include_records'] = True
4755
func_result = up_func(context, data_dict)
4856
backend = DatastoreSearchBackend.get_active_backend()
49-
backend.delete(dict(func_result))
57+
try:
58+
backend.delete(dict(func_result))
59+
except DatastoreSearchException:
60+
pass
5061
return func_result
5162

5263

@@ -64,7 +75,10 @@ def datastore_search(up_func: Action,
6475
ds_meta = up_func(context, {'resource_id': data_dict.get('resource_id'),
6576
'limit': 0})
6677
backend = DatastoreSearchBackend.get_active_backend()
67-
records = backend.search(data_dict)
78+
try:
79+
records = backend.search(dict(data_dict))
80+
except DatastoreSearchException:
81+
return up_func(context, data_dict)
6882
return dict(ds_meta, records=records)
6983

7084

@@ -74,5 +88,8 @@ def datastore_run_triggers(up_func: Action,
7488
data_dict: DataDict) -> ChainedAction:
7589
func_result = up_func(context, data_dict)
7690
backend = DatastoreSearchBackend.get_active_backend()
77-
backend.reindex(resource_id=data_dict.get('resource_id'))
91+
try:
92+
backend.reindex(resource_id=data_dict.get('resource_id'))
93+
except DatastoreSearchException:
94+
pass
7895
return func_result

0 commit comments

Comments
 (0)