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