Skip to content

Commit

Permalink
[#1078] don't use cache when indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Jul 15, 2013
1 parent 1f25727 commit e581105
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 7 additions & 8 deletions ckan/lib/search/__init__.py
Expand Up @@ -123,7 +123,8 @@ def notify(self, entity, operation):
dispatch_by_operation(
entity.__class__.__name__,
logic.get_action('package_show')(
{'model': model, 'ignore_auth': True, 'validate': False},
{'model': model, 'ignore_auth': True, 'validate': False,
'use_cache': False},
{'id': entity.id}),
operation
)
Expand All @@ -147,18 +148,18 @@ def rebuild(package_id=None, only_missing=False, force=False, refresh=False, def
log.info("Rebuilding search index...")

package_index = index_for(model.Package)
context = {'model': model, 'ignore_auth': True, 'validate': False,
'use_cache': False}

if package_id:
pkg_dict = logic.get_action('package_show')(
{'model': model, 'ignore_auth': True, 'validate': False},
pkg_dict = logic.get_action('package_show')(context,
{'id': package_id})
log.info('Indexing just package %r...', pkg_dict['name'])
package_index.remove_dict(pkg_dict)
package_index.insert_dict(pkg_dict)
elif package_ids:
for package_id in package_ids:
pkg_dict = logic.get_action('package_show')(
{'model': model, 'ignore_auth': True, 'validate': False},
pkg_dict = logic.get_action('package_show')(context,
{'id': package_id})
log.info('Indexing just package %r...', pkg_dict['name'])
package_index.update_dict(pkg_dict, True)
Expand All @@ -185,9 +186,7 @@ def rebuild(package_id=None, only_missing=False, force=False, refresh=False, def
for pkg_id in package_ids:
try:
package_index.update_dict(
logic.get_action('package_show')(
{'model': model, 'ignore_auth': True,
'validate': False},
logic.get_action('package_show')(context,
{'id': pkg_id}
),
defer_commit
Expand Down
4 changes: 3 additions & 1 deletion ckan/logic/action/get.py
Expand Up @@ -719,7 +719,9 @@ def package_show(context, data_dict):

package_dict = None
no_cache_context = ['revision_id', 'revision_date', 'schema']
if not any(k in context for k in no_cache_context):
use_cache = (context.get('use_cache', True)
and not any(k in context for k in no_cache_context))
if use_cache:
try:
package_dict = json.loads(search.show(name_or_id)['data_dict'])
if pkg.revision_id != package_dict.get('revision_id'):
Expand Down

0 comments on commit e581105

Please sign in to comment.