From ea05b4e0d655faa4d4ff2d3b7f187ea5b79af06c Mon Sep 17 00:00:00 2001 From: souliane Date: Wed, 21 May 2014 21:14:40 +0200 Subject: [PATCH] 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 --- src/memory/params.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/memory/params.py b/src/memory/params.py index 359c9bf8..52a812aa 100644 --- a/src/memory/params.py +++ b/src/memory/params.py @@ -756,7 +756,8 @@ class Params(object): 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 @@ class Params(object): 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@"):