summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--distixlib/ticket_store.py8
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]