Blame SOURCES/0221-dump_dir-introduce-dd_copy_file.patch

e7f1a6
From 117345107d77ebcea926aa339a572fa5de30fb95 Mon Sep 17 00:00:00 2001
e7f1a6
From: Jakub Filak <jfilak@redhat.com>
e7f1a6
Date: Fri, 12 Dec 2014 09:17:59 +0100
e7f1a6
Subject: [PATCH] dump_dir: introduce dd_copy_file()
e7f1a6
e7f1a6
Related to abrt/abrt#548
e7f1a6
e7f1a6
Signed-off-by: Jakub Filak <jfilak@redhat.com>
e7f1a6
---
e7f1a6
 src/include/dump_dir.h    |  1 +
e7f1a6
 src/lib/create_dump_dir.c | 10 +---------
e7f1a6
 src/lib/dump_dir.c        | 16 ++++++++++++++++
e7f1a6
 3 files changed, 18 insertions(+), 9 deletions(-)
e7f1a6
e7f1a6
diff --git a/src/include/dump_dir.h b/src/include/dump_dir.h
e7f1a6
index fff23f2..84cabbf 100644
e7f1a6
--- a/src/include/dump_dir.h
e7f1a6
+++ b/src/include/dump_dir.h
e7f1a6
@@ -96,6 +96,7 @@ char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned fla
e7f1a6
 char* dd_load_text(const struct dump_dir *dd, const char *name);
e7f1a6
 void dd_save_text(struct dump_dir *dd, const char *name, const char *data);
e7f1a6
 void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size);
e7f1a6
+int dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path);
e7f1a6
 /* Returns value less than 0 if any error occured; otherwise returns size of an
e7f1a6
  * item in Bytes. If an item does not exist returns 0 instead of an error
e7f1a6
  * value.
e7f1a6
diff --git a/src/lib/create_dump_dir.c b/src/lib/create_dump_dir.c
e7f1a6
index d683b8e..a96f7bd 100644
e7f1a6
--- a/src/lib/create_dump_dir.c
e7f1a6
+++ b/src/lib/create_dump_dir.c
e7f1a6
@@ -101,15 +101,7 @@ struct dump_dir *create_dump_dir_from_problem_data_ext(problem_data_t *problem_d
e7f1a6
 
e7f1a6
         if (value->flags & CD_FLAG_BIN)
e7f1a6
         {
e7f1a6
-            char *dest = concat_path_file(dd->dd_dirname, name);
e7f1a6
-            log_info("copying '%s' to '%s'", value->content, dest);
e7f1a6
-            off_t copied = copy_file(value->content, dest, DEFAULT_DUMP_DIR_MODE | S_IROTH);
e7f1a6
-            if (copied < 0)
e7f1a6
-                error_msg("Can't copy %s to %s", value->content, dest);
e7f1a6
-            else
e7f1a6
-                log_info("copied %li bytes", (unsigned long)copied);
e7f1a6
-            free(dest);
e7f1a6
-
e7f1a6
+            dd_copy_file(dd, name, value->content);
e7f1a6
             continue;
e7f1a6
         }
e7f1a6
 
e7f1a6
diff --git a/src/lib/dump_dir.c b/src/lib/dump_dir.c
e7f1a6
index 1e6ce64..d7ddec7 100644
e7f1a6
--- a/src/lib/dump_dir.c
e7f1a6
+++ b/src/lib/dump_dir.c
e7f1a6
@@ -1487,6 +1487,22 @@ int dd_mark_as_notreportable(struct dump_dir *dd, const char *reason)
e7f1a6
     return 0;
e7f1a6
 }
e7f1a6
 
e7f1a6
+int dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path)
e7f1a6
+{
e7f1a6
+    char *dest = concat_path_file(dd->dd_dirname, name);
e7f1a6
+
e7f1a6
+    log_debug("copying '%s' to '%s'", source_path, dest);
e7f1a6
+
e7f1a6
+    off_t copied = copy_file(source_path, dest, DEFAULT_DUMP_DIR_MODE | S_IROTH);
e7f1a6
+    if (copied < 0)
e7f1a6
+        error_msg("Can't copy %s to %s", source_path, dest);
e7f1a6
+    else
e7f1a6
+        log_debug("copied %li bytes", (unsigned long)copied);
e7f1a6
+
e7f1a6
+    free(dest);
e7f1a6
+    return copied < 0;
e7f1a6
+}
e7f1a6
+
e7f1a6
 /* flags - for future needs */
e7f1a6
 int dd_create_archive(struct dump_dir *dd, const char *archive_name,
e7f1a6
         const_string_vector_const_ptr_t exclude_elements, int flags)
e7f1a6
-- 
e7f1a6
1.8.3.1
e7f1a6