doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0063-cli-add-option-remove-crash-dirs-after-reporting.patch

baab13
From fa289049950f8c64455e94dd07bec2170a2d28e2 Mon Sep 17 00:00:00 2001
baab13
From: Matej Habrnal <mhabrnal@redhat.com>
baab13
Date: Sat, 20 Sep 2014 11:24:25 +0200
baab13
Subject: [ABRT PATCH 63/66] cli: add option remove crash dirs after reporting
baab13
baab13
Add option -d to abrt-cli report which allows delete dump dir after the problem
baab13
was successfully reported.
baab13
baab13
Resolves #1067545
baab13
baab13
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
baab13
Signed-off-by: Jakub Filak <jfilak@redhat.com>
baab13
---
baab13
 po/POTFILES.in   |  1 +
baab13
 src/cli/report.c | 18 ++++++++++++++++--
baab13
 2 files changed, 17 insertions(+), 2 deletions(-)
baab13
baab13
diff --git a/po/POTFILES.in b/po/POTFILES.in
baab13
index e3f917b..141c73a 100644
baab13
--- a/po/POTFILES.in
baab13
+++ b/po/POTFILES.in
baab13
@@ -51,6 +51,7 @@ src/cli/abrt-cli-core.c
baab13
 src/cli/abrt-cli.c
baab13
 src/cli/list.c
baab13
 src/cli/status.c
baab13
+src/cli/report.c
baab13
 
baab13
 src/plugins/analyze_CCpp.xml.in
baab13
 src/plugins/analyze_VMcore.xml.in
baab13
diff --git a/src/cli/report.c b/src/cli/report.c
baab13
index 3321a78..33d8b44 100644
baab13
--- a/src/cli/report.c
baab13
+++ b/src/cli/report.c
baab13
@@ -26,14 +26,20 @@ int cmd_report(int argc, const char **argv)
baab13
 {
baab13
     const char *program_usage_string = _(
baab13
         "& report [options] DIR..."
baab13
-        );
baab13
+    );
baab13
+
baab13
+    enum {
baab13
+        OPT_v = 1 << 0,
baab13
+        OPT_d = 1 << 1,
baab13
+    };
baab13
 
baab13
     struct options program_options[] = {
baab13
         OPT__VERBOSE(&g_verbose),
baab13
+        OPT_BOOL('d', "delete", NULL, _("Remove PROBLEM_DIR after reporting")),
baab13
         OPT_END()
baab13
     };
baab13
 
baab13
-    parse_opts(argc, (char **)argv, program_options, program_usage_string);
baab13
+    unsigned opts = parse_opts(argc, (char **)argv, program_options, program_usage_string);
baab13
     argv += optind;
baab13
 
baab13
     if (!argv[0])
baab13
@@ -58,6 +64,14 @@ int cmd_report(int argc, const char **argv)
baab13
         int status = report_problem_in_dir(dir_name,
baab13
                                              LIBREPORT_WAIT
baab13
                                            | LIBREPORT_RUN_CLI);
baab13
+
baab13
+        /* the problem was successfully reported and option is -d */
baab13
+        if((opts & OPT_d) && (status == 0 || status == EXIT_STOP_EVENT_RUN))
baab13
+        {
baab13
+            log(_("Deleting '%s'"), dir_name);
baab13
+            delete_dump_dir_possibly_using_abrtd(dir_name);
baab13
+        }
baab13
+
baab13
         free(free_me);
baab13
 
baab13
         if (status)
baab13
-- 
baab13
1.8.3.1
baab13