summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-03-25 13:24:29 +0200
committerLars Wirzenius <liw@liw.fi>2017-03-25 14:33:01 +0200
commit12e5b3fa9ee56c3cb68149a155b36aa1c2ba5c85 (patch)
treeedab622e7d1b652f02d3f5df0e65fbcf9c3f9237
parentca1b29cfdde31f20677d30a72fbf880e29fef396 (diff)
downloaddistix-12e5b3fa9ee56c3cb68149a155b36aa1c2ba5c85.tar.gz
Refactor: Check for ticket existence without loading all
-rw-r--r--distixlib/ticket_store.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/distixlib/ticket_store.py b/distixlib/ticket_store.py
index 3c6a09d..1a8b809 100644
--- a/distixlib/ticket_store.py
+++ b/distixlib/ticket_store.py
@@ -137,10 +137,9 @@ class TicketStore(object):
if ticket_id is None:
raise TicketHasNoId()
- for existing in self.get_tickets():
- if ticket_id == existing.get_ticket_id():
- raise distixlib.TicketAlreadyInStoreError(
- ticket_id=ticket_id, dirname=self._dirname)
+ if ticket_id in self.get_ticket_ids():
+ raise distixlib.TicketAlreadyInStoreError(
+ ticket_id=ticket_id, dirname=self._dirname)
self._dirty = True
self._ticket_cache.put(ticket)