From: Frank Schreiner Date: Tue, 5 Apr 2016 14:47:29 +0000 (+0000) Subject: fixed problem with baseurl while '--update' X-Git-Tag: upstream/0.10.0~12^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=059db9726f9ee9c59730172509d1125fbd717f75;p=services%2Fcreaterepo_c.git fixed problem with baseurl while '--update' --- diff --git a/src/createrepo_c.c b/src/createrepo_c.c index f86692c..7f028ec 100644 --- a/src/createrepo_c.c +++ b/src/createrepo_c.c @@ -852,10 +852,7 @@ main(int argc, char **argv) user_data.cut_dirs = cmd_options->cut_dirs; user_data.location_prefix = cmd_options->location_prefix; - if ( cmd_options->split && ! cmd_options->location_base) - user_data.location_base = "media://"; - else - user_data.location_base = cmd_options->location_base; + user_data.location_base = cmd_options->location_base; g_debug("Thread pool user data ready"); diff --git a/src/dumper_thread.c b/src/dumper_thread.c index 452983a..332b031 100644 --- a/src/dumper_thread.c +++ b/src/dumper_thread.c @@ -34,6 +34,7 @@ #include "misc.h" #include "parsepkg.h" #include "xml_dump.h" +#include "package.h" #define MAX_TASK_BUFFER_LEN 20 #define CACHEDCHKSUM_BUFFER_LEN 2048 @@ -221,6 +222,27 @@ exit: return checksum; } +int prepare_split_media_baseurl(int media_id,const char *location_base,cr_Package *pkg) +{ + // default location_base "media:" in split mode + if (!location_base) + location_base = "media:"; + + // calculate location_base + size_t lb_length = strlen(location_base); + gchar *t_location_base = g_malloc0(lb_length + 32); + strcpy(t_location_base, location_base); + if (lb_length > 3 && g_strcmp0(location_base + lb_length - 3, "://") == 0) + lb_length -= 2; + sprintf(t_location_base + lb_length, "#%d", media_id); + + pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, t_location_base); + + g_free(t_location_base); + + return 0; +} + static cr_Package * load_rpm(const char *fullpath, cr_ChecksumType checksum_type, @@ -248,19 +270,8 @@ load_rpm(const char *fullpath, if (!media_id) { pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, location_base); } else { - // default location_base "media:" in split mode - if (!location_base) - location_base = "media:"; - // calculate location_base - size_t lb_length = strlen(location_base); - gchar *t_location_base = g_malloc0(lb_length + 32); - strcpy(t_location_base, location_base); - if (lb_length > 3 && g_strcmp0(location_base + lb_length - 3, "://") == 0) - lb_length -= 2; - sprintf(t_location_base + lb_length, "#%d", media_id); - pkg->location_base = cr_safe_string_chunk_insert(pkg->chunk, t_location_base); - g_free(t_location_base); + prepare_split_media_baseurl(media_id, location_base, pkg); } pkg->location_href = cr_safe_string_chunk_insert(pkg->chunk, location_href); @@ -313,6 +324,7 @@ errexit: return NULL; } + void cr_dumper_thread(gpointer data, gpointer user_data) { @@ -418,6 +430,13 @@ cr_dumper_thread(gpointer data, gpointer user_data) } } else { // Just gen XML from old loaded metadata + if ( task->media_id ) { + if ( ! md->chunk ) { + g_debug("Creating new chunk"); + md->chunk = g_string_chunk_new (PACKAGE_CHUNK_SIZE); + } + prepare_split_media_baseurl(task->media_id, location_base, md); + } pkg = md; res = cr_xml_dump(md, &tmp_err); if (tmp_err) { diff --git a/src/package.c b/src/package.c index c026c32..30d5cb6 100644 --- a/src/package.c +++ b/src/package.c @@ -22,8 +22,6 @@ #include "package.h" #include "misc.h" -#define PACKAGE_CHUNK_SIZE 2048 - cr_Dependency * cr_dependency_new(void) { diff --git a/src/package.h b/src/package.h index be061ad..fc1324a 100644 --- a/src/package.h +++ b/src/package.h @@ -28,6 +28,8 @@ extern "C" { #include +#define PACKAGE_CHUNK_SIZE 2048 + /** \defgroup package Package representation. * \addtogroup package * @{