From 12e5b3fa9ee56c3cb68149a155b36aa1c2ba5c85 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 25 Mar 2017 13:24:29 +0200 Subject: Refactor: Check for ticket existence without loading all --- distixlib/ticket_store.py | 7 +++---- 1 file 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) -- cgit v1.2.1