diff src/memory/params.py @ 1042:59de0c7a28ec

memory (params): fixes bugs in setParam: - symbol 'd' was accessed without having been initialized when setting the empty value to a password which is not the profile password - the method was actually returning without waiting for the parameter to be set
author souliane <souliane@mailoo.org>
date Wed, 21 May 2014 21:14:40 +0200
parents 902c764a0d2b
children 85c110c0be86
line wrap: on
line diff
--- a/src/memory/params.py	Wed May 21 12:07:13 2014 +0200
+++ b/src/memory/params.py	Wed May 21 21:14:40 2014 +0200
@@ -756,7 +756,8 @@
         if type_ == "button":
             log.debug("Clicked param button %s" % node.toxml())
             return defer.succeed(None)
-        elif type_ == "password":
+        d = defer.succeed(value)
+        if type_ == "password":
             try:
                 personal_key = self.host.memory.auth_sessions.profileGetUnique(profile)[C.MEMORY_CRYPTO_KEY]
             except TypeError:
@@ -770,17 +771,16 @@
                 d = PasswordHasher.hash(value)  # profile password is hashed (empty value stays empty)
             elif value:  # other non empty passwords are encrypted with the personal key
                 d = BlockCipher.encrypt(personal_key, value)
-        else:
-            d = defer.succeed(value)
 
         def gotFinalValue(value):
             if self.host.isConnected(profile):  # key can not exists if profile is not connected
                 self.params[profile][(category, name)] = value
             self.host.bridge.paramUpdate(name, value, category, profile)
             self.host.trigger.point("paramUpdateTrigger", name, value, category, node[0], profile)
-            d_list.append(self.storage.setIndParam(category, name, value, profile))
+            return self.storage.setIndParam(category, name, value, profile)
 
         d.addCallback(gotFinalValue)
+        d_list.append(d)
         return defer.DeferredList(d_list).addCallback(lambda dummy: None)
 
     def _getNodesOfTypes(self, attr_type, node_type="@ALL@"):