dreport: remove unnecessary filed parts

Generating a content of a report bundle may fail, but leave incomplete
parts that increase the bundle size over the allowed limit.

For example: On the BMC with very big uptime `journal-pretty.log` may
overflow `/tmp` and lead to the bundle creation that even compressed is
longer than `RWFS`.

This prevents including such parts into the resulting bundle.

Change-Id: I24b29eaaac730c39735da7a032400e95f0710ff5
Signed-off-by: Alexander Filippov <a.filippov@yadro.com>
diff --git a/tools/dreport.d/include.d/functions b/tools/dreport.d/include.d/functions
index b62b471..24f5a12 100755
--- a/tools/dreport.d/include.d/functions
+++ b/tools/dreport.d/include.d/functions
@@ -14,6 +14,7 @@
     eval $command >> "$name_dir/$file_name"
     if [ $? -ne 0 ]; then
         log_error "Failed to collect $desc"
+        rm -f "$name_dir/$file_name"
         return 1
     fi
 
@@ -36,6 +37,7 @@
     cp -Lr $file_name $name_dir
     if [ $? -ne 0 ]; then
         log_error "Failed to copy $desc $file_name"
+        rm -fr "$name_dir/$file_name"
         return $RESOURCE_UNAVAILABLE
     fi
     if check_size "$name_dir/$(basename "$file_name")"; then
@@ -58,6 +60,7 @@
     cp $file_name $name_dir
     if [ $? -ne 0 ]; then
         log_error "Failed to copy $desc $file_name"
+        rm -fr "$name_dir/$file_name"
         return $RESOURCE_UNAVAILABLE
     fi
     if check_size "$name_dir/$(basename "$file_name")"; then