Skip to content

Commit b3e9fb8

Browse files
committed
rhbugzilla: Don't pull down attachments on refresh() (bz 1084887)
Attachments can be huge, and processing them hits the bugzilla server quite hard. Coupled with the fact that it's easy for bugs to hit refresh(), and users may inadvertently be contributing to bugzilla slowness. Doing a 'print bug.attachments' will still pull down the attachment data, it just isn't unconditionally fetched on bug.refresh() anymore.
1 parent 5d2f7a8 commit b3e9fb8

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

bugzilla/base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ def _find_comps():
820820
getbug_extra_fields = []
821821

822822

823-
def _getbugs(self, idlist, simple=False, permissive=True):
823+
def _getbugs(self, idlist, simple=False, permissive=True,
824+
extra_fields=None):
824825
'''
825826
Return a list of dicts of full bug info for each given bug id.
826827
bug ids that couldn't be found will return None instead of a dict.
@@ -840,7 +841,10 @@ def _getbugs(self, idlist, simple=False, permissive=True):
840841
if permissive:
841842
getbugdata["permissive"] = 1
842843
if self.getbug_extra_fields and not simple:
844+
# This means bugzilla actually supports extra_fields
843845
getbugdata["extra_fields"] = self.getbug_extra_fields
846+
if extra_fields:
847+
getbugdata["extra_fields"] += extra_fields
844848

845849
log.debug("Calling Bug.get_bugs with: %s", getbugdata)
846850
r = self._proxy.Bug.get_bugs(getbugdata)
@@ -866,9 +870,10 @@ def _getbugs(self, idlist, simple=False, permissive=True):
866870

867871
return ret
868872

869-
def _getbug(self, objid, simple=False):
873+
def _getbug(self, objid, simple=False, extra_fields=None):
870874
'''Return a dict of full bug info for the given bug id'''
871-
return self._getbugs([objid], simple=simple, permissive=False)[0]
875+
return self._getbugs([objid], simple=simple, permissive=False,
876+
extra_fields=extra_fields)[0]
872877

873878
def getbug(self, objid):
874879
'''Return a Bug object with the full complement of bug data

bugzilla/bug.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __getattr__(self, name):
9191

9292
log.debug("Bug %i missing attribute '%s' - doing refresh()",
9393
self.bug_id, name)
94-
self.refresh()
94+
self.refresh(fields=[name])
9595
refreshed = True
9696

9797
raise AttributeError("Bug object has no attribute '%s'" % name)
@@ -110,9 +110,9 @@ def __setstate__(self, d):
110110
self._update_dict(d)
111111
self.bugzilla = None
112112

113-
def refresh(self):
113+
def refresh(self, fields=None):
114114
'''Refresh all the data in this Bug.'''
115-
r = self.bugzilla._getbug(self.bug_id)
115+
r = self.bugzilla._getbug(self.bug_id, extra_fields=fields)
116116

117117
self._update_dict(r)
118118

bugzilla/rhbugzilla.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _add_both_alias(newname, origname):
7070

7171
getbug_extra_fields = (
7272
_parent.getbug_extra_fields + [
73-
"attachments", "comments", "description",
73+
"comments", "description",
7474
"external_bugs", "flags", "sub_components",
7575
"tags",
7676
]

0 commit comments

Comments
 (0)