Blob Blame History Raw
From eb38c73cc3aa81884e74718c6d7f412ea7a94f6f Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 4 Aug 2015 19:35:48 +0200
Subject: [PATCH] dd: don't warn about missing 'type' if the locking fails

The warning is printed out at least 10 times and makes only a little
sense to system administrators. abrtd follows those warnings with
"$path is not a valid problem directory" message which is a sufficient
way to tell the administrators to remove that directory.

Related: rhbz#1243280

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 src/lib/dump_dir.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
index aed7a15..2399ca1 100644
--- a/src/lib/dump_dir.c
+++ b/src/lib/dump_dir.c
@@ -384,7 +384,16 @@ static const char *dd_check(struct dump_dir *dd)
         return FILENAME_TIME;
     }
 
-    dd->dd_type = load_text_file_at(dd->dd_fd, FILENAME_TYPE, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE);
+    /* Do not warn about missing 'type' file in non-verbose modes.
+     *
+     * Handling of FILENAME_TYPE should be consistent with handling of
+     * FILENAME_TIME in the function parse_time_file_at() where the missing
+     * file message is printed by log_info() (in a verbose mode).
+     */
+    int load_flags = DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE;
+    if (g_verbose < 2) load_flags |= DD_FAIL_QUIETLY_ENOENT;
+
+    dd->dd_type = load_text_file_at(dd->dd_fd, FILENAME_TYPE, load_flags);
     if (!dd->dd_type || (strlen(dd->dd_type) == 0))
     {
         log_debug("Missing or empty file: "FILENAME_TYPE);
-- 
2.4.3