Forráskód Böngészése

Simplify _get_cipher

oz123 10 éve
szülő
commit
f62fb17b48
1 módosított fájl, 10 hozzáadás és 4 törlés
  1. 10 4
      pwman/util/crypto.py

+ 10 - 4
pwman/util/crypto.py

@@ -311,10 +311,7 @@ class CryptoEngine(object):
         """
         self._cipher = None
 
-    def _getcipher(self):
-        """
-        get cypher from user, to decrypt DB
-        """
+    def _pre_check_get_chiper(self):
         if (self._cipher is not None
             and (self._timeout == -1
                  or (time.time() -
@@ -325,6 +322,15 @@ class CryptoEngine(object):
         if self._keycrypted is None:
             raise CryptoNoKeyException("Encryption key has not been generated")
 
+
+
+    def _getcipher(self):
+        """
+        get cypher from user, to decrypt DB
+        """
+        if self._pre_check_get_chiper():
+            return self._cipher
+
         max_tries = 5
         tries = 0
         key = None