Blame SOURCES/0202-rhtsupport-attach-all-dump-dir-s-element-to-a-new-ca.patch

28bab8
From 4df6adff7f2393fc228b0437a1c8be172ff7370e Mon Sep 17 00:00:00 2001
28bab8
From: Matej Habrnal <mhabrnal@redhat.com>
28bab8
Date: Thu, 3 Mar 2016 10:39:46 +0100
28bab8
Subject: [PATCH] rhtsupport: attach all dump dir's element to a new case
28bab8
28bab8
Before this commit there were attached only binary files and an xml file which
28bab8
contains all text dump dir's files at once.
28bab8
With this commit reporter-rhtsupport attaching all dump dir's files separately.
28bab8
28bab8
Because we don't know if someone uses the xml file, the reporter attaches the
28bab8
xml files as well.
28bab8
28bab8
Related to: rhbz#1261358
28bab8
28bab8
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
28bab8
---
28bab8
 src/plugins/reporter-rhtsupport.c | 35 +++++++++++++++++++++++++++--------
28bab8
 1 file changed, 27 insertions(+), 8 deletions(-)
28bab8
28bab8
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
28bab8
index 781b5b1..63a24a5 100644
28bab8
--- a/src/plugins/reporter-rhtsupport.c
28bab8
+++ b/src/plugins/reporter-rhtsupport.c
28bab8
@@ -73,7 +73,8 @@ static report_result_t *get_reported_to(const char *dump_dir_name)
28bab8
 }
28bab8
 
28bab8
 static
28bab8
-int create_tarball(const char *tempfile, problem_data_t *problem_data)
28bab8
+int create_tarball(const char *tempfile, struct dump_dir *dd,
28bab8
+     problem_data_t *problem_data)
28bab8
 {
28bab8
     reportfile_t *file = NULL;
28bab8
     int retval = 0; /* everything is ok so far .. */
28bab8
@@ -126,15 +127,28 @@ int create_tarball(const char *tempfile, problem_data_t *problem_data)
28bab8
                         /*recorded_filename*/ xml_name,
28bab8
                         /*binary           */ !(value->flags & CD_FLAG_BIGTXT)
28bab8
                 );
28bab8
-                if (tar_append_file(tar, (char*)content, xml_name) != 0)
28bab8
-                {
28bab8
-                    free(xml_name);
28bab8
-                    goto ret_fail;
28bab8
-                }
28bab8
                 free(xml_name);
28bab8
             }
28bab8
         }
28bab8
     }
28bab8
+
28bab8
+    /* append all files from dump dir */
28bab8
+    dd_init_next_file(dd);
28bab8
+    char *short_name, *full_name;
28bab8
+    while (dd_get_next_file(dd, &short_name, &full_name))
28bab8
+    {
28bab8
+        char *uploaded_name = concat_path_file("content", short_name);
28bab8
+        free(short_name);
28bab8
+
28bab8
+        if (tar_append_file(tar, full_name, uploaded_name) != 0)
28bab8
+        {
28bab8
+            free(full_name);
28bab8
+            goto ret_fail;
28bab8
+        }
28bab8
+
28bab8
+        free(full_name);
28bab8
+    }
28bab8
+
28bab8
     const char *signature = reportfile_as_string(file);
28bab8
     /*
28bab8
      * Note: this pointer points to string which is owned by
28bab8
@@ -200,6 +214,7 @@ ret_fail:
28bab8
     }
28bab8
 
28bab8
 ret_clean:
28bab8
+    dd_close(dd);
28bab8
     /* now it's safe to free file */
28bab8
     free_reportfile(file);
28bab8
     return retval;
28bab8
@@ -777,7 +792,11 @@ int main(int argc, char **argv)
28bab8
     /* Gzipping e.g. 0.5gig coredump takes a while. Let user know what we are doing */
28bab8
     log(_("Compressing data"));
28bab8
 
28bab8
-    if (create_tarball(tempfile, problem_data) != 0)
28bab8
+    struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
28bab8
+    if (!dd)
28bab8
+        xfunc_die(); /* error msg is already logged by dd_opendir */
28bab8
+
28bab8
+    if (create_tarball(tempfile, dd, problem_data) != 0)
28bab8
     {
28bab8
         errmsg = _("Can't create temporary file in "LARGE_DATA_TMP_DIR);
28bab8
         goto ret;
28bab8
@@ -850,7 +869,7 @@ int main(int argc, char **argv)
28bab8
         }
28bab8
         /* No error in case creation */
28bab8
         /* Record "reported_to" element */
28bab8
-        struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
28bab8
+        dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
28bab8
         if (dd)
28bab8
         {
28bab8
             struct report_result rr = { .label = (char *)"RHTSupport" };
28bab8
-- 
28bab8
1.8.3.1
28bab8