abrt/0021-a-a-s-p-data-reduce-amount-of-error-messages.patch
2014-09-01 09:20:09 +02:00

54 lines
2.3 KiB
Diff

From 3829489cd5f74f4b9f7e1567fee941123aa77987 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Wed, 27 Aug 2014 08:45:24 +0200
Subject: [PATCH 21/24] a-a-s-p-data: reduce amount of error messages
Read each GPG key only once. The GPG key dirs may contain many symlinks
and if their target cannot be read, then we print an error message for
every symlink pointing to the unreadable file. What's worse, the error
messages show a path to the target, so users see several identical
messages in the system logs.
Related to rhbz#1133674
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/daemon/abrt-action-save-package-data.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index 6dbcfc2..cc86327 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -91,16 +91,22 @@ static void load_gpg_keys(void)
if (strcmp(gpg_keys_dir, "") != 0)
{
log_debug("Reading gpg keys from '%s'", gpg_keys_dir);
+ GHashTable *done_set = g_hash_table_new(g_str_hash, g_str_equal);
GList *gpg_files = get_file_list(gpg_keys_dir, NULL /* we don't care about the file ext */);
- GList *tmp_gpp_files = gpg_files;
- while (tmp_gpp_files)
+ for (GList *iter = gpg_files; iter; iter = g_list_next(iter))
{
- log_debug("Loading gpg key '%s'", fo_get_fullpath((file_obj_t *)tmp_gpp_files->data));
- settings_setOpenGPGPublicKeys = g_list_append(settings_setOpenGPGPublicKeys, xstrdup(fo_get_fullpath((file_obj_t *)(tmp_gpp_files->data)) ));
- tmp_gpp_files = g_list_next(tmp_gpp_files);
+ const char *key_path = fo_get_fullpath((file_obj_t *)iter->data);
+
+ if (g_hash_table_contains(done_set, key_path))
+ continue;
+
+ g_hash_table_insert(done_set, (gpointer)key_path, NULL);
+ log_debug("Loading gpg key '%s'", key_path);
+ settings_setOpenGPGPublicKeys = g_list_append(settings_setOpenGPGPublicKeys, xstrdup(key_path));
}
g_list_free_full(gpg_files, (GDestroyNotify)free_file_obj);
+ g_hash_table_destroy(done_set);
}
}
--
2.1.0