Commits

Christian Hofstaedtler  committed 1d04469

Don't busy loop when setting a db-session-added Paste to private.

  • Participants
  • Parent commits 657194c
  • Branches lodgeit

Comments (0)

Files changed (1)

File lodgeit/models.py

         if self.private_id is None:
             while 1:
                 self.private_id = generate_paste_hash()
-                paste = Paste.query.filter(Paste.private_id ==
-                                           self.private_id).first()
+                paste = Paste.query.filter(db.and_(Paste.private_id ==
+                                           self.private_id,
+                                           Paste.paste_id != self.paste_id)) \
+                                   .first()
                 if paste is None:
                     break
     private = property(_get_private, _set_private, doc='''