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

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