diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-29 18:39:29 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-29 18:39:29 +0300 |
commit | bc8b0b2682522587742ac65091e3ea005c0f94e6 (patch) | |
tree | fcbdce10997e29bc21a07f5a706570e496c58609 | |
parent | 6e25d72697484b39802ebb4ceee71b87685d21d3 (diff) | |
download | distix-bc8b0b2682522587742ac65091e3ea005c0f94e6.tar.gz |
Only load ticket matching requested id
-rw-r--r-- | distixlib/ticket_store.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/distixlib/ticket_store.py b/distixlib/ticket_store.py index 1a8b809..2343e2e 100644 --- a/distixlib/ticket_store.py +++ b/distixlib/ticket_store.py @@ -78,7 +78,10 @@ class TicketStore(object): '''Return a distixlib.Ticket for an existing ticket in the store.''' ticket_id = self._find_ticket_id_from_prefix(ticket_id_or_prefix) - assert ticket_id in self._ticket_cache + if ticket_id not in self._ticket_cache: + ticket_dir = self._get_dir_for_ticket(ticket_id) + ticket = self._load_ticket(ticket_dir) + self._ticket_cache.put(ticket) return self._ticket_cache.get(ticket_id) def _find_ticket_id_from_prefix(self, prefix): @@ -87,8 +90,7 @@ class TicketStore(object): if len(matches) == 1: return matches[0] - tickets = self.get_tickets() - ticket_ids = [t.get_ticket_id() for t in tickets] + ticket_ids = self.get_ticket_ids() matches = self._find_ticket_ids_matching_prefix(ticket_ids, prefix) if len(matches) == 1: return matches[0] |