allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject allura git commit: When reindexing, set c.app based on current artifact to avoid e.g. "Ambiguous link to #16 and c.app is not present to remove ambiguity"
Date Wed, 18 Oct 2017 19:10:31 GMT
Repository: allura
Updated Branches:
  refs/heads/master ec15cd29f -> bb0326c0f


When reindexing, set c.app based on current artifact to avoid e.g. "Ambiguous link to #16
and c.app is not present to remove ambiguity"


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/bb0326c0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/bb0326c0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/bb0326c0

Branch: refs/heads/master
Commit: bb0326c0f5a81c552fbc032a9afb0e959839cf66
Parents: ec15cd2
Author: Dave Brondsema <dave@brondsema.net>
Authored: Wed Oct 18 14:51:26 2017 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Oct 18 14:51:26 2017 -0400

----------------------------------------------------------------------
 Allura/allura/tasks/index_tasks.py | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/bb0326c0/Allura/allura/tasks/index_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/index_tasks.py b/Allura/allura/tasks/index_tasks.py
index 916c6fd..792eeab 100644
--- a/Allura/allura/tasks/index_tasks.py
+++ b/Allura/allura/tasks/index_tasks.py
@@ -20,7 +20,9 @@ import logging
 from contextlib import contextmanager
 
 from pylons import app_globals as g
+from pylons import tmpl_context as c
 
+from allura.lib import helpers as h
 from allura.lib.decorators import task
 from allura.lib.exceptions import CompoundError
 from allura.lib.solr import make_solr_from_config
@@ -87,19 +89,21 @@ def add_artifacts(ref_ids, update_solr=True, update_refs=True, solr_hosts=None):
                 artifact = ref.artifact
                 if artifact is None:
                     continue
-                s = artifact.solarize()
-                if s is None:
-                    continue
-                if update_solr:
-                    solr_updates.append(s)
-                if update_refs:
-                    if isinstance(artifact, M.Snapshot):
+                # c.app is normally set, so keep using it.  During a reindex its not though,
so set it from artifact
+                with h.push_config(c, app=getattr(c, 'app', None) or artifact.app):
+                    s = artifact.solarize()
+                    if s is None:
                         continue
-                    # Find shortlinks in the raw text, not the escaped html
-                    # created by the `solarize()`.
-                    link_text = artifact.index().get('text') or ''
-                    shortlinks = find_shortlinks(link_text)
-                    ref.references = [link.ref_id for link in shortlinks]
+                    if update_solr:
+                        solr_updates.append(s)
+                    if update_refs:
+                        if isinstance(artifact, M.Snapshot):
+                            continue
+                        # Find shortlinks in the raw text, not the escaped html
+                        # created by the `solarize()`.
+                        link_text = artifact.index().get('text') or ''
+                        shortlinks = find_shortlinks(link_text)
+                        ref.references = [link.ref_id for link in shortlinks]
             except Exception:
                 log.error('Error indexing artifact %s', ref._id)
                 exceptions.append(sys.exc_info())


Mime
View raw message