Rework debug output in passwd_store_set() to be less confusing.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 19 Oct 2018 21:36:40 +0000 (23:36 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Sat, 27 Oct 2018 17:15:58 +0000 (19:15 +0200)
src/passwordstore.c

index 7a6322a1d8dda4cd95a1fea50633122a34660d39..6bab54cec2c2a77f90fa730a83f4df09da7bce68 100644 (file)
@@ -155,16 +155,18 @@ gboolean passwd_store_set(PasswordBlockType block_type,
                }
        }
 
-       debug_print("%s password for '%s' in block (%d/%s)%s\n",
-                       (p == NULL ? "Deleting" : "Storing"),
-                       password_id, block_type, block_name,
-                       (encrypted ? ", already encrypted" : "") );
-
        if (p == NULL) {
                /* NULL password was passed to us, so delete the entry with
-                * corresponding id */
-               g_hash_table_remove(block->entries, password_id);
+                * corresponding id, if it exists */
+               if (g_hash_table_lookup(block->entries, password_id) != NULL) {
+                       debug_print("Deleting password for '%s' in block (%d/%s)\n",
+                                       password_id, block_type, block_name);
+                       g_hash_table_remove(block->entries, password_id);
+               }
        } else {
+               debug_print("Setting password for '%s' in block (%d/%s)%s\n",
+                               password_id, block_type, block_name,
+                               (encrypted ? ", already encrypted" : ""));
                if (!encrypted) {
                        /* encrypt password before saving it */
                        if ((encrypted_password =